环境部署与使用
新的改变
- 计算图 Graph
- 会话Session
- 变量管理 共享reuse
- define-and-run
忘记TensorFlow1.0,从头学习
环境部署
- 下载安装anaconda
conda 确认:cmd下执行 conda list
-
cuda 10.0 安装:
NVIDIA显卡 (GTX 1060 1080Ti)
CUDA 驱动*最好选择custom 最好取消NVIDIA GeForce Experience co... 最好取消visual studio integration Driver components 对比驱动版本与当前电脑驱动版本,如果电脑驱动新于将安装的驱动,一定要取消勾选*
cuDNN 安装(安装对应CUDA的版本),解压复制到cuda的目录,修改名字为cudnn
PATH配置
测试安装:nvcc -V -
安装TensorFlow
pip install --upgrade tensorflow
pip install --upgrade tensorflow-gpupip install tensorflow== 2.0.0-alpha0
pip install tensorflow-gpu == 2.0.0-alpha0
验证:
ipython
import tensorflow as tf
tf.constant(1.0)+tf.constant(9.0) #显示<tf.Tensor: id=10, shape=(), dtype=float32, numpy=10.0>
tf.test.is_gpu_available() #显示True就是可用
安装pycharm,选择安装的环境,可以开始开发啦
centos 7.0
查看是否有显卡:lspci
03:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
03:00.1 Audio device: NVIDIA Corporation GP102 HDMI Audio Controller (rev a1)
04:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
04:00.1 Audio device: NVIDIA Corporation GP102 HDMI Audio Controller (rev a1)
下载cuda:
https://developer.nvidia.com/cuda-toolkit
nvidia-smi
Thu Apr 25 07:28:42 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.48 Driver Version: 390.48 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 108... Off | 00000000:03:00.0 Off | N/A |
| 33% 35C P0 55W / 250W | 0MiB / 11178MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 GeForce GTX 108... Off | 00000000:04:00.0 Off | N/A |
| 33% 38C P0 55W / 250W | 0MiB / 11178MiB | 3% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
卸载旧版本
/usr/local/cuda-9.0/bin/uninstall_cuda_9.0.pl
sudo sh cuda_10.0.130_410.48_linux.run
accept
n(不要安装driver)
y
y
y
打开主目录下的 .bashrc文件,将相关路径按下面的格式进行修改。例如我的.bashrc文件,root 用户 cd 回车即可
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64
export PATH=$PATH:/usr/local/cuda-9.0/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-9.0
在终端运行:source ~/.bashrc
下载cudnn
https://developer.nvidia.com/rdp/cudnn-archive
tar -xvf cudnn.solitairetheme8
sudo cp include/cudnn.h /usr/local/cuda/include/
sudo cp lib64/lib* /usr/local/cuda/lib64/