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

相关推荐
Yan-英杰38 分钟前
百度搜索和文心智能体接入DeepSeek满血版——AI搜索的新纪元
图像处理·人工智能·python·深度学习·deepseek
weixin_307779132 小时前
Azure上基于OpenAI GPT-4模型验证行政区域数据的设计方案
数据仓库·python·云计算·aws
玩电脑的辣条哥3 小时前
Python如何播放本地音乐并在web页面播放
开发语言·前端·python
taoqick3 小时前
对PosWiseFFN的改进: MoE、PKM、UltraMem
人工智能·pytorch·深度学习
多想和从前一样5 小时前
Django 创建表时 “__str__ ”方法的使用
后端·python·django
charles_vaez6 小时前
开源模型应用落地-LangGraph101-探索 LangGraph 短期记忆
深度学习·语言模型·自然语言处理
WHATEVER_LEO7 小时前
【每日论文】Latent Radiance Fields with 3D-aware 2D Representations
人工智能·深度学习·神经网络·机器学习·计算机视觉·自然语言处理
小喵要摸鱼7 小时前
【Pytorch 库】自定义数据集相关的类
pytorch·python
bdawn7 小时前
深度集成DeepSeek大模型:WebSocket流式聊天实现
python·websocket·openai·api·实时聊天·deepseek大模型·流式输出
Jackson@ML7 小时前
Python数据可视化简介
开发语言·python·数据可视化