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

1 引言

电脑配置

Windows 11

cuda 12.0

RTX4090

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

2 步骤

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

txt 复制代码
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.*

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

txt 复制代码
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

(2)添加环境变量

txt 复制代码
D:\ProgramData\anaconda3\envs\tf39\Lib\site-packages\nvidia\cudnn\bin

(3)测试

txt 复制代码
import tensorflow as tf
print(tf.test.is_gpu_available())

如果报错"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'。注意先复制一个文件后备份,再重命名。

相关推荐
JavaEdge在掘金7 分钟前
cursor 1.2发布!Agent规划、更好上下文支持 & 更快的 Tab 补全!
python
CoovallyAIHub13 分钟前
RTMPose:重新定义多人姿态估计的“实时”标准!
深度学习·算法·计算机视觉
巴里巴气37 分钟前
Python爬虫用Clash软件设置代理IP
爬虫·python·tcp/ip
Whoisshutiao1 小时前
Python网安-zip文件暴力破解(仅供学习)
开发语言·python·网络安全
龙潜月七1 小时前
Selenium 自动化测试中跳过机器人验证的完整指南:能用
python·selenium·机器人
hjs_deeplearning2 小时前
认知篇#10:何为分布式与多智能体?二者联系?
人工智能·分布式·深度学习·学习·agent·智能体
瑶光守护者2 小时前
【卫星通信】超低比特率语音编解码器(ULBC)的信道特性评估
深度学习·华为·卫星通信·3gpp·ulbc
蓝婷儿3 小时前
Python 机器学习核心入门与实战进阶 Day 1 - 分类 vs 回归
python·机器学习·分类
Devil枫4 小时前
Kotlin扩展函数与属性
开发语言·python·kotlin