当前位置:   article > 正文

Windows11+CUDA12.0+RTX4090如何配置安装Tensorflow2-GPU环境?_tensorflow cuda12

tensorflow cuda12

1 引言

电脑配置
在这里插入图片描述

Windows 11
cuda 12.0
RTX4090

由于tensorflow2官网已经不支持cuda11以上的版本了,配置cuda和tensorflow可以通过以下步骤配置实现。

2 步骤

(1)创建conda环境并安装cuda和cudnn,以及安装tensorflow2.10

conda create -n tf39 python=3.9.*  numpy=1.20
conda activate tf39
conda install -c conda-forge cudatoolkit=11.8.*
pip install nvidia-cudnn-cu11
pip install tensorflow==2.10.*
  • 1
  • 2
  • 3
  • 4
  • 5

完整的不冲突的包环境如下,包括sklearn、matplotlib、pandas等

absl-py                      2.1.0
anyio                        4.4.0
argon2-cffi                  23.1.0
argon2-cffi-bindings         21.2.0
arrow                        1.3.0
asttokens                    2.4.1
astunparse                   1.6.3
async-lru                    2.0.4
attrs                        23.2.0
Babel                        2.15.0
beautifulsoup4               4.12.3
bleach                       6.1.0
cachetools                   5.3.3
certifi                      2024.6.2
cffi                         1.16.0
charset-normalizer           3.3.2
clang                        5.0
clifford                     1.4.0
colorama                     0.4.6
comm                         0.2.2
contourpy                    1.2.1
cycler                       0.12.1
debugpy                      1.8.1
decorator                    5.1.1
defusedxml                   0.7.1
exceptiongroup               1.2.1
executing                    2.0.1
fastjsonschema               2.20.0
flatbuffers                  24.3.25
fonttools                    4.53.0
fqdn                         1.5.1
gast                         0.4.0
google-auth                  2.30.0
google-auth-oauthlib         0.4.6
google-pasta                 0.2.0
grpcio                       1.64.1
h11                          0.14.0
h5py                         3.6.0
httpcore                     1.0.5
httpx                        0.27.0
idna                         3.7
importlib_metadata           7.1.0
importlib_resources          6.4.0
install                      1.3.5
ipykernel                    6.29.4
ipython                      8.18.1
ipywidgets                   8.1.3
isoduration                  20.11.0
jedi                         0.19.1
Jinja2                       3.1.4
joblib                       1.2.0
json5                        0.9.25
jsonpointer                  3.0.0
jsonschema                   4.22.0
jsonschema-specifications    2023.12.1
jupyter                      1.0.0
jupyter_client               8.6.2
jupyter-console              6.6.3
jupyter_core                 5.7.2
jupyter-events               0.10.0
jupyter-lsp                  2.2.5
jupyter_server               2.14.1
jupyter_server_terminals     0.5.3
jupyterlab                   4.2.2
jupyterlab_pygments          0.3.0
jupyterlab_server            2.27.2
jupyterlab_widgets           3.0.11
keras                        2.10.0
Keras-Preprocessing          1.1.2
kiwisolver                   1.4.5
libclang                     18.1.1
llvmlite                     0.36.0
Markdown                     3.6
MarkupSafe                   2.1.5
matplotlib                   3.3.4
matplotlib-inline            0.1.7
mistune                      3.0.2
mpl-toolkits.clifford        0.0.3
nbclient                     0.10.0
nbconvert                    7.16.4
nbformat                     5.10.4
nest-asyncio                 1.6.0
notebook                     7.2.1
notebook_shim                0.2.4
numba                        0.53.0
numpy                        1.20.0
nvidia-cublas-cu11           11.11.3.6
nvidia-cuda-nvrtc-cu11       11.8.89
nvidia-cudnn-cu11            9.1.1.17
oauthlib                     3.2.2
opt-einsum                   3.3.0
overrides                    7.7.0
packaging                    24.1
pandas                       1.4.0
pandocfilters                1.5.1
parso                        0.8.4
pillow                       10.3.0
pip                          24.0
platformdirs                 4.2.2
prometheus_client            0.20.0
prompt_toolkit               3.0.47
protobuf                     3.19.6
psutil                       6.0.0
pure-eval                    0.2.2
pyasn1                       0.6.0
pyasn1_modules               0.4.0
pycparser                    2.22
Pygments                     2.18.0
pyparsing                    3.1.2
python-dateutil              2.9.0.post0
python-json-logger           2.0.7
pytz                         2024.1
pywin32                      306
pywinpty                     2.0.13
PyYAML                       6.0.1
pyzmq                        26.0.3
qtconsole                    5.5.2
QtPy                         2.4.1
referencing                  0.35.1
requests                     2.32.3
requests-oauthlib            2.0.0
rfc3339-validator            0.1.4
rfc3986-validator            0.1.1
rpds-py                      0.18.1
rsa                          4.9
scikit-learn                 1.5.0
scipy                        1.10.0
Send2Trash                   1.8.3
setuptools                   69.5.1
six                          1.15.0
sniffio                      1.3.1
soupsieve                    2.5
sparse                       0.15.4
stack-data                   0.6.3
tensorboard                  2.10.1
tensorboard-data-server      0.6.1
tensorboard-plugin-wit       1.8.1
tensorflow                   2.10.1
tensorflow-estimator         2.10.0
tensorflow-io-gcs-filesystem 0.31.0
termcolor                    1.1.0
terminado                    0.18.1
threadpoolctl                3.1.0
tinycss2                     1.3.0
tomli                        2.0.1
tornado                      6.4.1
traitlets                    5.14.3
trimesh                      4.4.1
types-python-dateutil        2.9.0.20240316
typing_extensions            4.12.2
tzdata                       2024.1
uri-template                 1.3.0
urllib3                      2.2.2
wcwidth                      0.2.13
webcolors                    24.6.0
webencodings                 0.5.1
websocket-client             1.8.0
Werkzeug                     3.0.3
wheel                        0.43.0
widgetsnbextension           4.0.11
wrapt                        1.12.1
zipp                         3.19.2
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162

(2)添加环境变量

D:\ProgramData\anaconda3\envs\tf39\Lib\site-packages\nvidia\cudnn\bin
  • 1

(3)测试

import tensorflow as tf
print(tf.test.is_gpu_available())
  • 1
  • 2

如果报错”tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cudnn64_8.dll’; dlerror: cudnn64_8.dll not found”
请将路径D:\ProgramData\anaconda3\envs\tf39\Lib\site-packages\nvidia\cudnn\bin下的’cudnn64_8.dll’重命名为’cudnn64_9.dll’。注意先复制一个文件后备份,再重命名。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/972576
推荐阅读
相关标签
  

闽ICP备14008679号