Ubuntu + Anaconda + Tensorflow 安装和配置教程

袁英豪
2023-12-01

Envornment

  • Ubuntu 18.4
  • CUDA Version: 10.0
  • CUDNN Version: 7.6.5

Check CUDA & CUDNN version

#CUDA
nvidia-smi
nvcc -version

#CUDNN
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
---------------------------------------------result----------------------------------------
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 6
#define CUDNN_PATCHLEVEL 5
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

#include "driver_types.h"

Tensorflow version correspondence

Install anaconda

tip: 安装anaconda前是不需要在系统上安装python滴~,安装anaconda时python也会被安装。

The archive has older versions of Anaconda Individual Edition installers

第一步:下载和安装

下载Anaconda X86_64版本到你指定的路径下

wget https://repo.anaconda.com/archive/Anaconda3-5.3.1-Linux-x86_64.sh

使用bash指令进行anaconda安装:

bash Anaconda3-5.3.1-Linux-x86_64.sh

配置环境变量(Anaconda3)

export PATH=~/anaconda3/bin:$PATH

安装完成后使用指令查看安装结果:

conda info

第二步:在anaconda下新建环境

使用指令进行创建自己的环境并指定python版本

conda create -n your_env_name python=3.6

使用指令进入刚创建的环境下进行tensorflow安装:

source activate your_env_name

第三步:国内镜像

#check sources
conda config --show-sources

#add sources
conda config --add channels http://mirrors.aliyun.com/pypi/simple/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free

#delete sources
conda config --remove channels http://mirrors.aliyun.com/pypi/simple/

第四步:安装相应的库,有现有顺序

pip install tensorflow-gpu
pip install opencv

PS. 确保服务器GPU已经安装CUDA和CUDNN,需要将该环境引入到新账号的环境变量中:

# 1、编辑环境变量
vim ~/.bashrc
 
# 2、在文件的最后添加以下内容
# cuda-9.0
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
 
# 3、使用命令验证CUDA添加成功
nvcc -V

 

文件传输:FileZilla

Linux 入门教程——服务器使用

Check Ubuntu Version:

$ lsb_release -a

Creating folders and files

$ mkdir /tmp/tutorial
$ cd /tmp/tutorial
$ mkdir dir1 dir2 dir3
$ ls

Anaconda managing environments

Ubuntu common commands
check CPU memory$ top
check GPU memory

#single checking
$ nvidia-smi 
#smi - System management interface

#real time monitoring, refreshing once every second
$ watch -n 1 nvidia-smi

check disk space$ df -h
delete folderrm -R folder-name
rename foldersmv old-name new-name
move foldersmv old-directory new-directory
copy folders

cp -r  old-directory new-directory 

#r-copy recursively

shows current working directorypwd
list the detail information of files and folder of a current directoryls -l / ll
check directory sizedu -sh path

Refferences

 类似资料: