MXNet(DL)

#install basic tool

sudo apt-get update
sudo apt-get install -y build-essential git 

#compile and install opencv

#download, compile and install opencv
sudo apt-get install libopencv-dev

#install one blas: openblas/Apple/atlas/mkl

#download, compile and install one blas version
sudo apt-get install libopenblas-dev
#sudo apt-get install libblas-dev
#sudo apt-get install libatlas-dev

#cublas is in cuda, and is for GPU

#install cuda (include cublas cusparse)

wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_8.0.61-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1404_8.0.61-1_amd64.deb
(
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb
)
sudo apt-get update
sudo apt-get install cuda

#check gpu
nvidia-smi

#install cudnn (no need)

#instal cudnn


#download and compile mxnet

git clone --recursive https://github.com/dmlc/mxnet
cd mxnet

#compile
mv make/config.mk config.mk
atom config.mk
    USE_CUDA = 1
    USE_CUDA_PATH = /usr/local/cuda
    USE_BLAS = openblas
make -j8


#support python

cd python
python setup.py install


#add cuda lib

#export LD_LIBRARY_PATH=/usr/local/cuda/targets/x86_64-linux/lib/:$LD_LIBRARY_PAT


#train using cpu

cd example/mnist
python mlp.py


#train using gpu

model = mx.model.FeedForward(
        ctx = mx.cpu(), symbol = mlp, num_epoch = 20,
        learning_rate = 0.1, momentum = 0.9, wd = 0.00001)  
=>
model = mx.model.FeedForward(
        ctx = mx.gpu(), symbol = mlp, num_epoch = 20,
        learning_rate = 0.1, momentum = 0.9, wd = 0.00001)   


#training resnet

git clone https://github.com/tornadomeet/ResNet.git
cd ResNet
im2rec_path train.lst train/ data/imagenet/train_480_q90.rec resize=480 quality=90
python -u train_resnet.py --data-dir data/imagenet --data-type imagenet --depth 50 --batch-size 256  --gpus=0,1,2,3,4,5

 

赞 (0) 评论 分享 ()