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

相关推荐
多巴胺与内啡肽.31 分钟前
深度学习--自然语言处理统计语言与神经语言模型
深度学习·语言模型·自然语言处理
偶尔微微一笑40 分钟前
AI网络渗透kali应用(gptshell)
linux·人工智能·python·自然语言处理·编辑器
深度之眼1 小时前
2025时间序列都有哪些创新点可做——总结篇
人工智能·深度学习·机器学习·时间序列
船长@Quant2 小时前
文档构建:Sphinx全面使用指南 — 基础篇
python·markdown·sphinx·文档构建
喵手2 小时前
从 Java 到 Kotlin:在现有项目中迁移的最佳实践!
java·python·kotlin
liuweidong08022 小时前
【Pandas】pandas DataFrame rsub
开发语言·python·pandas
CH3_CH2_CHO3 小时前
不吃【Numpy】版
开发语言·python·numpy
不吃香菜?3 小时前
PyTorch 实现食物图像分类实战:从数据处理到模型训练
人工智能·深度学习
-曾牛3 小时前
企业级AI开发利器:Spring AI框架深度解析与实战
java·人工智能·python·spring·ai·rag·大模型应用
Light604 小时前
智启未来:深度解析Python Transformers库及其应用场景
开发语言·python·深度学习·自然语言处理·预训练模型·transformers库 |·|应用场景