diff --git a/scripts/install/purge-cuda.sh b/scripts/install/purge-cuda.sh index a62b46a5625..caaabed5c37 100644 --- a/scripts/install/purge-cuda.sh +++ b/scripts/install/purge-cuda.sh @@ -1,5 +1,4 @@ #!/bin/bash - sudo apt-get --purge remove nvidia-* sudo apt-get --purge remove cuda-* sudo apt-get --purge remove cudnn-* diff --git a/scripts/install/ubuntu-conda.sh b/scripts/install/ubuntu-conda.sh index a7895312af7..10744381ac5 100644 --- a/scripts/install/ubuntu-conda.sh +++ b/scripts/install/ubuntu-conda.sh @@ -2,6 +2,7 @@ set -ex MINDSPORE_VERSION=${MINDSPORE_VERSION:-1.5.0} +PYTHON_VERSION=${PYTHON_VERSION:-3.7.5} #use huaweicloud mirror in China sudo sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list @@ -14,14 +15,14 @@ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 100 cd /tmp curl -O https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py37_4.10.3-Linux-x86_64.sh -bash Miniconda3-py37_4.10.3-Linux-x86_64.sh +bash Miniconda3-py37_4.10.3-Linux-x86_64.sh -b # add conda to PATH echo -e 'export PATH=~/miniconda3/bin/:$PATH' >> ~/.bash_profile echo -e '. ~/miniconda3/etc/profile.d/conda.sh' >> ~/.bash_profile source ~/.bash_profile conda init bash -# setting up conda mirror +# setting up conda mirror with qinghua source cat >~/.condarc < example.py <> ~/.bash_profile - echo -e '. ~/miniconda3/etc/profile.d/conda.sh' >> ~/.bash_profile - source ~/.bash_profile +echo -e 'export PATH=~/miniconda3/bin/:$PATH' >> ~/.bash_profile +echo -e '. ~/miniconda3/etc/profile.d/conda.sh' >> ~/.bash_profile +source ~/.bash_profile conda init bash # setting up conda mirror cat >~/.condarc <> ~/.bash_profile - -echo "install gmp success" -# install cuda with apt-get -echo "install cuda start" - -wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin -sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 -wget -c https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda-repo-ubuntu1804-11-1-local_11.1.1-455.32.00-1_amd64.deb -sudo dpkg -i cuda-repo-ubuntu1804-11-1-local_11.1.1-455.32.00-1_amd64.deb -sudo apt-key add /var/cuda-repo-ubuntu1804-11-1-local/7fa2af80.pub -sudo apt-get update -sudo apt-get -y install cuda - -# add cuda to path -cat >> ~/.bash_profile <> ~/.bash_profile - echo 'export PATH=$PATH:/usr/local/openmpi/bin' >> ~/.bash_profile - source ~/.bash_profile -fi +# echo "install gmp start" +# sudo apt-get install m4 -y +# cd /tmp +# curl -O https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz +# xz -d gmp-6.1.2.tar.xz +# tar xvzf gmp-6.1.2.tar && cd gmp-6.1.2 +# ./configure --prefix=/usr/local/gmp-6.1.2 +# make +# sudo make install +# echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gmp-6.1.2/lib' >> ~/.bash_profile # install mindspore-gpu with conda -conda install mindspore-gpu=${MINDSPORE_VERSION} cudatoolkit=${CUDATOOLKIT_VERSION} cudnn=${CUDNN_VERSION} -c mindspore -c conda-forge +conda install mindspore-gpu=${MINDSPORE_VERSION} cudatoolkit=${CUDATOOLKIT_VERSION} -c mindspore -c conda-forge -y + +# check if it is the right mindspore version +python -c "import mindspore;mindspore.run_check()" + +# check if it can be run with GPU + +cat > example.py < ~/.pip/pip.conf <> ~/.bash_profile - -# install cuda with linux.run -# another option is to use https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run - -wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin -sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 -wget -c https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda-repo-ubuntu1804-11-1-local_11.1.1-455.32.00-1_amd64.deb -sudo dpkg -i cuda-repo-ubuntu1804-11-1-local_11.1.1-455.32.00-1_amd64.deb -sudo apt-key add /var/cuda-repo-ubuntu1804-11-1-local/7fa2af80.pub +# install cuda/cudnn/nccl2 with apt-get +# another option is to use linux.run https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run +sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub +sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" +sudo add-apt-repository "deb https://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu1804/x86_64/ /" sudo apt-get update -sudo apt-get -y install cuda +sudo apt-get -y install cuda=${CUDA_VERSION} # add cuda to path cat >> ~/.bash_profile <> ~/.bash_profile - echo 'export PATH=$PATH:/usr/local/openmpi/bin' >> ~/.bash_profile - source ~/.bash_profile -fi +# uncomment this to compile openmpi +# cd /tmp +# curl -O https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.3.tar.gz +# tar xvzf openmpi-4.0.3.tar.gz +# cd openmpi-4.0.3 +# ./configure --prefix=/usr/local/openmpi +# make +# sudo make install +# echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openmpi/lib' >> ~/.bash_profile +# echo 'export PATH=$PATH:/usr/local/openmpi/bin' >> ~/.bash_profile +# source ~/.bash_profile +# reference this to install tensorrt https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html#downloading -# install mindspore gpu +echo "install mindspore gpu ${MINDSPORE_VERSION}" +pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/${MINDSPORE_VERSION}/MindSpore/gpu/${ARCH}/${CUDA_INSTALL_PATH}/mindspore_gpu-${version_map["$PYTHON_VERSION"]}-linux_${ARCH}.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple -pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/${MINDSPORE_VERSION}/MindSpore/gpu/${CUDA_INSTALL_PATH}/mindspore-${VERSION}-linux_${ARCH}.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple \ No newline at end of file + +# check if it is the right mindspore version +python -c "import mindspore;mindspore.run_check()" + +# check if it can be run with GPU + +cat > example.py < example.py <