1.安装nccl --> caffe/tensorflow multi-gpu
git clone https://github.com/NVIDIA/nccl.git
cd nccl
make -j src.build CUDA_HOME=/usr/local/cuda-9.0 NVCC_GENCODE="-gencode=arch=compute_70,code=sm_70"
make install(optional: 安装于系统路径下"/path/to/nccl/build/lib/libnccl.so" -> "/usr/local/lib/libnccl.so"
cp: 无法创建符号链接"/usr/local/lib/libnccl.so": 权限不够)
export LD_LIBRARY_PATH=/path/to/your/nccl/build/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
2.杀死某个用户的所有进程
pkill -9 -U username
3.查看用户进程
top -U username
4.添加头文件目录至系统
include头文件路径
除了默认的/usr/include, /usr/local/include等include路径外,还可以通过设置环境变量来添加系统include的路径:
# C
export C_INCLUDE_PATH=XXXX:$C_INCLUDE_PATH
# CPP
export CPLUS_INCLUDE_PATH=XXX:$CPLUS_INCLUDE_PATH
5.nccl续
无sudo,conda install nccl后 分别添加include/lib路径 caffe Makefile.config tensorflow1.12还不支持要.so.2 手动编译的报bug暂时 noknow
6.opencv
cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_CUDA=OFF -D WITH_CUFFT=OFF -D WITH_TIFF=ON -D BUILD_TIFF=ON -D CMAKE_INSTALL_PREFIX=/home/zhengzhe/Install/dependencies/opencv3.2/ -D WITH_LIBV4L=ON -D WITH_V4L=ON -D WITH_FFMPEG=ON -D WITH_IPP=OFF ..
make -j
make install
export OpenCV_DIR=/home/zhengzhe/Install/dependencies/opencv3.2/share/OpenCV/(覆盖系统opencv路径)
7.无权限安装gcc5.3.0
wget ftp://mirrors.kernel.org/gnu/gcc/gcc-5.3.0/gcc-5.3.0.tar.gz
tar -zxvf gcc-5.3.0.tar.gz
cd gcc-5.3.0
./contrib/download_prerequisites cd ..
mkdir gcc-build-5.3.0 cd gcc-build-5.3.0
../gcc-5.3.0/configure --prefix=/home/zhengzhe/Install/dependencies/gcc5.3.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j make install
export PATH=/your/path/to/gcc/bin:PATH
8.安装leveldb
git clone https://github.com/google/leveldb.git
mkdir -p build && cd build
cmake -D CMAKE_INSTALL_PREFIX=../../Leveldb/ -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ..
make -j
make install
9.安装OpenBlas
git clone git://github.com/xianyi/OpenBLAS
make -j
make PREFIX=/your/path/to/install install
10.gflag
git clone https://github.com/gflags/gflags.git
cd gflags
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/your/path/to/ -DBUILD_SHARED_LIBS=ON ..
make -j
make install
11.glog
git clone https://github.com/google/glog.git
cd glog
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/your/path/to/ -DBUILD_SHARED_LIBS=ON .. #指定安装位置
make -j
make install
12.compile caffe
源码编译gflag、glog、openblas、leveldb
anaconda 安装lmdb protobuf nccl boost
修改Makefile.Config ~/.bashrc
13.git push
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git init
git add .
git commit -m "first commit"
git remote add origin "/path/to/your/url/.git"
git push -u origin master(dev)
(optional)
git fetch origin master:tmp
git rebase tmp
git push origin HEAD:master
git branch -D tmp
14.caffe
1.层注册
F0108 16:50:04.598269 34482 layer_factory.hpp:70] Check failed: registry.count(type) == 0 (1 vs. 0) Layer type BinaryConvolution already registered.
solutions: comment //REGISTER_LAYER_CLASS(/you/corresponding/layer.cpp);
2.网络架构prototxt中层名决定参数拷贝 而非是 blob名
15
I experimented with this a bit. I found that we should use the formula:
num_worker = 4 * num_GPU .
Though a factor of 2 and 8 also work good but lower factor (<2) significantly reduces overall performance. Here, worker has no impact on GPU memory allocation. Also, nowadays there are many CPU cores in a machine with few GPUs (<8), so the above formula is practical.
16 .matplotlib
先save后show,正常保存图片
import numpy as np
import matplotlib.pyplot as plt
t = np.arange(0, 69, 1)
plt.plot(t, t, 'r', t, t**2, 'b')
label = ['t', 't**2']
plt.legend(label, loc='upper left')
plt.savefig('./test2.jpg')
plt.show()