tensorflow pytorch环境安装

1.查看cuda版本(无关)

wlsh@wlsh-thinkstation-p920:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Apr_24_19:10:27_PDT_2019
Cuda compilation tools, release 10.1, V10.1.168

wlsh@wlsh-thinkstation-p920:~$ cat /usr/local/cuda/version.txt
CUDA Version 10.1.168
wlsh
@wlsh-thinkstation-p920:~$ cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
cat: /usr/local/cuda/include/cudnn.h: No such
file or directory

 

2.安装anaconda虚拟环境

wlsh@wlsh-thinkstation-p920:~$ conda create -n py3_torch python=3.6 
wlsh
@wlsh-thinkstation-p920:~$ conda activate py3_torch
(py3_torch) wlsh
@wlsh-thinkstation-p920:~$

 

3.安装opencv

(py3_torch) wlsh@wlsh-thinkstation-p920:~$ conda install opencv

 

4.安装pytorch和torchvision

https://pytorch.org

 

(py3_torch) wlsh@wlsh-thinkstation-p920:~$ conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

 

5.安装tensorflow和tensorboardX

https://www.zhihu.com/people/arsliv/posts

(py3_torch) wlsh@wlsh-thinkstation-p920:~$ conda install tensorflow-gpu
(py3_torch) wlsh
@wlsh-thinkstation-p920:~$ pip install tensorboardX

 

6.jupyter notebook关联此虚拟环境

(py3_torch) wlsh@wlsh-thinkstation-p920:~$ conda install nb_conda

 

7.端口重定向

本地mac连接远程服务器jupter notebook方法

https://www.digitalocean.com/community/tutorials/how-to-install-run-connect-to-jupyter-notebook-on-remote-server

[wlsh@wlsh-MacbookPro] ~$ ssh -L 8000:localhost:8888 wlsh@10.19.127.168
(base) wlsh
@wlsh-ThinkStation-P920:~$ jupyter notebook
http://localhost:8000

本地mac连接远程服务器可视化tensorboardX

参考:https://blog.csdn.net/weixin_35653315/article/details/71327740

#连接ssh时,将远程服务器的6006端口重定向到Mac
[wlsh@wlsh-MacbookPro] ~$ ssh -L 16006:127.0.0.1:6006 wlsh@10.19.127.168
#使用6006端口启动tensorboard
(base) wlsh@wlsh-thinkstation-p920:~/Desktop/wlsh/MyTestCode$ tensorboard --logdir=./log --port=6006
#Mac浏览器输入地址
127.0.0.1:16006

8.本地pycharm使用远程服务器的python解释器,并编辑服务器的代码

Configure a remote interpterter using SSH : https://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html

Pycharm - > Preferences

 

Creating a Remote Server Configuration:  https://www.jetbrains.com/help/pycharm/creating-a-remote-server-configuration.html

Tools - > Deployment

 

9.解决加载外面的py文件不成功方法:

https://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython

%load_ext autoreload
%autoreload 2

 

10.cell输出多行

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity =
"all"

你可能感兴趣的:(软件安装)