环境
联想小新潮 7000
Windows 10 64bit
Anaconda 2020.11
nvidia Geforce 940MX
安装anaconda
清华镜像站下载最新版的64位conda安装包,建议用迅雷,安装一路next即可,注意最后一步添加到环境变量打勾(我的版本Anaconda3-2020.11-Windows-x86_64)。
更换清华源
参考https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
创建虚拟环境
打开anaconda power sell prompt,输入
conda create tf21 python=3.7
安装相关软件包
conda activate tf21
conda install cudatoolkit=10.1
conda install cudnn=7.6
pip install tensorflow==2.1
pip install
检验
ipython
(tf21) PS C:\Users\xxx> ipython
Python 3.7.10 (default, Feb 26 2021, 13:06:18) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.21.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import tensorflow as tf
2021-03-11 20:12:21.775787: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
In [2]: tf.__version__
Out[2]: '2.1.0'
In [3]: tf.config.experimental.list_physical_devices()
2021-03-11 20:12:56.514961: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2021-03-11 20:12:56.925086: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce 940MX computeCapability: 5.0
coreClock: 1.189GHz coreCount: 3 deviceMemorySize: 2.00GiB deviceMemoryBandwidth: 37.33GiB/s
2021-03-11 20:12:56.925688: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2021-03-11 20:12:56.979579: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2021-03-11 20:12:57.027801: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2021-03-11 20:12:57.039221: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2021-03-11 20:12:57.091905: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2021-03-11 20:12:57.112422: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2021-03-11 20:12:57.211038: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2021-03-11 20:12:57.408208: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
Out[3]:
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'),
PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
In [4]:
安装完成。
参考
- https://www.bilibili.com/video/BV1B7411L7Qt?p=1