(3.1)搜索python path,Python: Default Interpreter Path设置了/opt/anaconda3/bin/python3
这样依赖包是anaconda下的,numpy已经导入过了,暂时没有设置自己的虚拟环境
(3.2)搜索python.pythonPath,设置了/opt/anaconda3/bin/python3
参考连接:https://blog.csdn.net/qq_17783559/article/details/119737541
(1)需要用到tf,配置了虚拟环境,参考连接:
https://blog.csdn.net/weixin_40100431/article/details/82116171
(2)根据base创造一个名称为py3tf12gpu的虚拟环境
dell@dell-PowerEdge-R740:/opt/anaconda3/bin$ conda create --name py3tf12gpu --clone base
(3)solve problem :
conda cannot use
dell@dell-PowerEdge-R740:/opt/anaconda3/bin$ source /opt/anaconda3/etc/profile.d/conda.sh
dell@dell-PowerEdge-R740:/opt/anaconda3/bin$ conda activate py3tf12gpu
(py3tf12gpu) dell@dell-PowerEdge-R740:/opt/anaconda3/bin$ conda deactivate
上面方法,只能临时起作用,重新启动终端时需要运行上面的语句,才可以正常使用conda激活环境
source /opt/anaconda3/etc/profile.d/conda.sh
conda activate py3tf12gpu
退出
conda deactivate
用conda init bash解决了,但每次进入都是base
用下面的语句进行处理,
关闭每次启动前面带有一个(bash)
conda config --set auto_activate_base false
重新开启
conda config --set auto_activate_base true
参照如下连接:https://tensorflow.google.cn/install?hl=zh-cn
安装了最新的稳定的tf
pip install --upgrade pip
pip install tensorflow
测试tf时出现问题,缺libcudart.so.11.0
参考解决:
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=18.04&target_type=deb_local
https://blog.csdn.net/qq_44703886/article/details/112393149
暂时考虑利用容器中的环境。use jupyter
(6.1)create contianer
docker run -itd -p 8888:8888 --name tf12-test floydhub/tensorflow:1.12-gpu.cuda9cudnn7-py3_aws.40 /bin/bash
(6.2)run into contianer
docker exec -it tf12-test /bin/bash
(6.3)first run:
jupyter notebook “$@” --allow-root
(6.4)firefox brower
http://127.0.0.1:8888/?token=2a534d460eede8d2c93be5c4e410bf78f400d2b15b7d1fd1
https://zhuanlan.zhihu.com/p/94378201
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#install-guide
先前安装的docker不变,从下面这步开始
Setting up NVIDIA Container Toolkit
dell@dell-PowerEdge-R740:~$ sudo apt-get install -y nvidia-docker2
配置文件 ‘/etc/docker/daemon.json’
==> 系统中的这个文件或者是由您创建的,或者是由脚本建立的。
==> 软件包维护者所提供的软件包中也包含了该文件。
您现在希望如何处理呢? 您有以下几个选择:
Y 或 I :安装软件包维护者所提供的版本
N 或 O :保留您原来安装的版本
D :显示两者的区别
Z :把当前进程切换到后台,然后查看现在的具体情况
默认的处理方法是保留您当前使用的版本。
*** daemon.json (Y/I/N/O/D/Z) [默认选项=N] ? N
正在处理用于 libc-bin (2.31-0ubuntu9.2) 的触发器 …
dell@dell-PowerEdge-R740:~$ sudo systemctl restart docker
test:
dell@dell-PowerEdge-R740:~$ sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
(8.1)运行gpu
有个用户手册:
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/user-guide.html
(8.1.1)docker run -itd -p 8888:8888 --gpus all --name tf12-test floydhub/tensorflow:1.12-gpu.cuda9cudnn7-py3_aws.40 /bin/bash
(8.1.2)run into contianer
docker exec -it tf12-test /bin/bash
(8.1.3)first run:
jupyter notebook “$@” --allow-root
(8.1.4)firefox brower
http://127.0.0.1:8888/?token=59f31c9d3a0e257cdd0612b22554edcb7a756a7683ee0067
(8.2)在容器中关联本地文件夹,在创建容器时,设置挂在卷,
创建:
docker run -itd -p 8888:8888 --gpus all --name tf12-test -v /home/dell/liuyang_works/docker-tf-gpu-rel:/home floydhub/tensorflow:1.12-gpu.cuda9cudnn7-py3_aws.40 /bin/bash
使用与8.1相同:
结论:需要可视化的部分,在容器中
(9.1)在虚拟环境中,可以使用tf了,下面将vscode下的路径设置为虚拟环境的,
(10.1)根据版本对照表:https://blog.csdn.net/K1052176873/article/details/114526086
本机的配置:
dell@dell-PowerEdge-R740:~$ nvcc -V
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
NVIDIA-SMI 470.86 Driver Version: 470.86 CUDA Version: 11.4
CUDA Toolkit Toolkit Driver Version
CUDA 10.0.130 >= 410.48
Version Python version Compiler Build tools cuDNN CUDA
tensorflow_gpu-2.0.0 3.5-3.7 MSVC 2017 Bazel 0.26.1 7.4.2 10
cuda和cudnn版本对照表
https://developer.nvidia.com/rdp/cudnn-archive
(10.2)具体步骤:
参照:https://blog.csdn.net/weixin_40100431/article/details/82116171
https://blog.csdn.net/weixin_40588315/article/details/85881338
1)创造一个相同环境
conda create -n py3tf pip python=3.7
虚拟环境的位置
environment location: /home/dell/.conda/envs/py3tf
2)进入虚拟环境
3)安装cuda
conda install cudatoolkit=10.0 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
4)安装cudnn,只有7.6.5能下载到
conda install cudnn=7.6.5 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/
5)安装tensorflow
版本匹配:https://tensorflow.google.cn/install/source_windows?hl=en#gpu
pip install tensorflow-gpu==2.2.0
6)测试成功
python进入
import tensorflow as tf
print(tf.test.is_gpu_available())
7)设置vscode的路径
虚拟环境的位置
environment location: /home/dell/.conda/envs/py3tf
还需要装numpy,pandas
setting
搜索python path,Python: Default Interpreter Path设置了/home/dell/.conda/envs/py3tf/bin/python3
搜索python.pythonPath,设置了/home/dell/.conda/envs/py3tf/bin/python3
8)后续问题解决,安装的tf2.0.0,源码需要的是tf1.0,于是作了如下处理,代码可运行
import tensorflow as tf
替换成下面代码。
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()