继承自:https://www.jianshu.com/p/0d1c4547d7d2
由于最开始以为GTX960M显卡仅仅能支持cuda9.0,但是在2021年1月26日,英伟达非常良心地更新驱动,让GTX960M也支持cuda11了(感谢英伟达!)
- https://blog.csdn.net/zhw864680355/article/details/90411288
- https://www.nvidia.cn/drivers/results/167551/
- https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
一、更新驱动
根据:https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#cuda-general-new-features
1.1 下载GTX960M对应的安装程序
https://www.nvidia.cn/geforce/drivers/
1.2 安装
1.3 更新驱动
1.4 查看对应cuda版本
二、查看tensorflow、python、cuda、cudnn版本对应关系:
https://tensorflow.google.cn/install/source_windows
三、 下载库:
3.1 在anconda中创建conda环境
启动powershell
3.2 更改源,加快下载速度
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/
conda config --set show_channel_urls yes
3.3 安装:
python -m pip install --upgrade pip
pip install keras -i https://pypi.douban.com/simple
conda install cudatoolkit=11.0
conda install cudnn=8.0
pip install tensorflow-gpu==2.4 -i https://pypi.douban.com/simple
#conda install tensorflow-gpu
pip3 install pillow -i https://pypi.douban.com/simple/
继续安装:
pip install -U keras-tuner -i https://pypi.douban.com/simple/
conda install matplotlib
pip install opencv-python -i https://pypi.douban.com/simple/
安装jupyter notebook补齐插件
python -m pip install jupyter_contrib_nbextensions -i https://pypi.douban.com/simple
jupyter contrib nbextension install --user --skip-running-check
安装完成后,勾选 “Table of Contents” 以及 “Hinterland”
参考:https://blog.csdn.net/weixin_41524411/article/details/99170460
四、检查
(Tensorflow2_4) PS C:\Users\Robin> python
Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2021-02-16 17:26:59.052272: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
>>> tf .__version__
'2.4.0'
>>>
(Tensorflow2_3) PS D:\Data\Tensorflow\human_horse> jupyter notebook
实际测试:
有些奇怪 GPU占用率变低了,更多调用的是CPU
后面发现其实后台显卡是占用了97%了,任务管理器还是认为是只占了30%