[{"data":1,"prerenderedAt":434},["ShallowReactive",2],{"content-query-nlbkjWSWy3":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"category":13,"body":14,"_type":428,"_id":429,"_source":430,"_file":431,"_stem":432,"_extension":433},"/technology-blogs/zh/3268","zh",false,"","MindSpore 1.7自动安装 GPU篇","MindSpore 1.7推出一个方便的安装方式，自动安装，试着体验一下","2024-08-13","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/11/28/d1e2edb25e7f49599fd6cadae35f2800.png","technology-blogs","安装",{"type":15,"children":16,"toc":425},"root",[17,25,30,43,48,56,61,66,73,78,83,90,95,100,105,112,117,122,127,134,139,144,149,156,161,168,173,178,185,190,197,204,209,214,219,224,229,236,241,246,251,256,274,279,283,333,338,342,347,352,356,361,366,379,384,389,408,413,420],{"type":18,"tag":19,"props":20,"children":22},"element","h1",{"id":21},"mindspore-17自动安装-gpu篇",[23],{"type":24,"value":8},"text",{"type":18,"tag":26,"props":27,"children":28},"p",{},[29],{"type":24,"value":9},{"type":18,"tag":26,"props":31,"children":32},{},[33,35],{"type":24,"value":34},"官网操作指南链接是：",{"type":18,"tag":36,"props":37,"children":41},"a",{"href":38,"rel":39},"https://www.mindspore.cn/install",[40],"nofollow",[42],{"type":24,"value":38},{"type":18,"tag":26,"props":44,"children":45},{},[46],{"type":24,"value":47},"我选择的是cuda 10.1+py3.7的版本",{"type":18,"tag":26,"props":49,"children":50},{},[51],{"type":18,"tag":52,"props":53,"children":55},"img",{"alt":7,"src":54},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/3610f951529648e0b920b03609bd21e0.png",[],{"type":18,"tag":26,"props":57,"children":58},{},[59],{"type":24,"value":60},"1. 第一步 根据安装说明：在使用自动安装脚本之前，需要确保系统正确安装了NVIDIA GPU驱动。CUDA 10.1要求最低显卡驱动版本为418.39；CUDA 11.1要求最低显卡驱动版本为450.80.02。执行以下指令检查驱动版本。",{"type":18,"tag":26,"props":62,"children":63},{},[64],{"type":24,"value":65},"nvidia-smi",{"type":18,"tag":26,"props":67,"children":68},{},[69],{"type":18,"tag":52,"props":70,"children":72},{"alt":7,"src":71},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/d0777122b55e45138cbc0a5251ed801f.png",[],{"type":18,"tag":26,"props":74,"children":75},{},[76],{"type":24,"value":77},"确认是418.39 真好合适",{"type":18,"tag":26,"props":79,"children":80},{},[81],{"type":24,"value":82},"2. 第二步下载安装脚本",{"type":18,"tag":26,"props":84,"children":85},{},[86],{"type":18,"tag":52,"props":87,"children":89},{"alt":7,"src":88},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/69029aad90a549a280c088de83809b71.png",[],{"type":18,"tag":26,"props":91,"children":92},{},[93],{"type":24,"value":94},"在官网解释中，说的是支持1.6.0及以上的版本，但是当我选择1.6版本的时候，并没有写着自动安装，这个我也不确定1.6支不支持",{"type":18,"tag":26,"props":96,"children":97},{},[98],{"type":24,"value":99},"还是按照1.7的来",{"type":18,"tag":26,"props":101,"children":102},{},[103],{"type":24,"value":104},"获取安装脚本",{"type":18,"tag":26,"props":106,"children":107},{},[108],{"type":18,"tag":52,"props":109,"children":111},{"alt":7,"src":110},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/640fdee848464966b3295a27facfad38.png",[],{"type":18,"tag":26,"props":113,"children":114},{},[115],{"type":24,"value":116},"3. 执行脚本发现存在问题：",{"type":18,"tag":26,"props":118,"children":119},{},[120],{"type":24,"value":121},"MINDSPORE_VERSION=1.7.0 bash -i ./ubuntu-gpu-pip.sh",{"type":18,"tag":26,"props":123,"children":124},{},[125],{"type":24,"value":126},"CUDA 11.1 minimum required driver version is 450.80.02, but current nvidia driver version is 418.39, please upgrade your driver manually.",{"type":18,"tag":26,"props":128,"children":129},{},[130],{"type":18,"tag":52,"props":131,"children":133},{"alt":7,"src":132},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/bfc8c2af94884966aa4bc6d72ecdbd77.png",[],{"type":18,"tag":26,"props":135,"children":136},{},[137],{"type":24,"value":138},"我明明是cuda10.1, 为什么报11.1呢",{"type":18,"tag":26,"props":140,"children":141},{},[142],{"type":24,"value":143},"查看脚本发现",{"type":18,"tag":26,"props":145,"children":146},{},[147],{"type":24,"value":148},"脚本里面CUDA_VERSION=${CUDA_VERSION:-11.1} 设置的cuda是11.1， 需要手动改成10.1",{"type":18,"tag":26,"props":150,"children":151},{},[152],{"type":18,"tag":52,"props":153,"children":155},{"alt":7,"src":154},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/6dbdbc3b1b5b4bd382605dea92aac5b9.png",[],{"type":18,"tag":26,"props":157,"children":158},{},[159],{"type":24,"value":160},"4. 再次执行脚本",{"type":18,"tag":26,"props":162,"children":163},{},[164],{"type":18,"tag":52,"props":165,"children":167},{"alt":7,"src":166},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/8ea1e133101f424495465fd32cbc09a6.png",[],{"type":18,"tag":26,"props":169,"children":170},{},[171],{"type":24,"value":172},"中间有点长，只截部分",{"type":18,"tag":26,"props":174,"children":175},{},[176],{"type":24,"value":177},"下面显示安装成功",{"type":18,"tag":26,"props":179,"children":180},{},[181],{"type":18,"tag":52,"props":182,"children":184},{"alt":7,"src":183},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/eb6deb17a299454fb5a605b0a310b1ec.png",[],{"type":18,"tag":26,"props":186,"children":187},{},[188],{"type":24,"value":189},"下面显示执行脚本成功",{"type":18,"tag":26,"props":191,"children":192},{},[193],{"type":18,"tag":52,"props":194,"children":196},{"alt":7,"src":195},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/1e6ea6dd15ad40a082ee8821dab7f0f5.png",[],{"type":18,"tag":26,"props":198,"children":199},{},[200],{"type":18,"tag":52,"props":201,"children":203},{"alt":7,"src":202},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/0d4c56c90daa46a29963337d0c4580fd.png",[],{"type":18,"tag":26,"props":205,"children":206},{},[207],{"type":24,"value":208},"5. 最后我们来分析下脚本：",{"type":18,"tag":26,"props":210,"children":211},{},[212],{"type":24,"value":213},"PYTHON_VERSION=${PYTHON_VERSION:-3.7} MINDSPORE_VERSION=${MINDSPORE_VERSION:EMPTY} CUDA_VERSION=${CUDA_VERSION:-10.1} OPENMPI=${OPENMPI:-off}",{"type":18,"tag":26,"props":215,"children":216},{},[217],{"type":24,"value":218},"OPENMPI为on 可以自动安装mpi",{"type":18,"tag":26,"props":220,"children":221},{},[222],{"type":24,"value":223},"但是由于我的机器已经安装，所以保留原来的off",{"type":18,"tag":26,"props":225,"children":226},{},[227],{"type":24,"value":228},"看自己机器有没有安装mpi可以执行一下mpirun",{"type":18,"tag":26,"props":230,"children":231},{},[232],{"type":18,"tag":52,"props":233,"children":235},{"alt":7,"src":234},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/9af61b13ce1a4d16a1a55b018cb7eacd.png",[],{"type":18,"tag":26,"props":237,"children":238},{},[239],{"type":24,"value":240},"上面就代表安装了",{"type":18,"tag":26,"props":242,"children":243},{},[244],{"type":24,"value":245},"inimum_driver_version_map[\"10.1\"]=\"418.39\" minimum_driver_version_map[\"11.1\"]=\"450.80.02\"",{"type":18,"tag":26,"props":247,"children":248},{},[249],{"type":24,"value":250},"两个cuda分别匹配的显卡驱动版本",{"type":18,"tag":26,"props":252,"children":253},{},[254],{"type":24,"value":255},"脚本：",{"type":18,"tag":26,"props":257,"children":258},{},[259,261,267,269],{"type":24,"value":260},"# python sudo add-apt-repository -y ppa:deadsnakes/ppa sudo apt-get install python$PYTHON_VERSION python$PYTHON_VERSION-distutils python3-pip -y sudo update-alternatives --install /usr/bin/python python /usr/bin/python$PYTHON_VERSION 100 # pip python -m pip install -U pip -i ",{"type":18,"tag":36,"props":262,"children":265},{"href":263,"rel":264},"https://pypi.tuna.tsinghua.edu.cn/simple",[40],[266],{"type":24,"value":263},{"type":24,"value":268}," echo -e \"alias pip='python -m pip'\" >> ~/.bashrc python -m pip config set global.index-url ",{"type":18,"tag":36,"props":270,"children":272},{"href":263,"rel":271},[40],[273],{"type":24,"value":263},{"type":18,"tag":26,"props":275,"children":276},{},[277],{"type":24,"value":278},"通过APT安装Python3和pip3",{"type":18,"tag":26,"props":280,"children":281},{},[282],{"type":24,"value":255},{"type":18,"tag":26,"props":284,"children":285},{},[286,288,295,297,304,306,313,315,322,324,331],{"type":24,"value":287},"# install cuda/cudnn echo \"installing CUDA and cuDNN\" cd /tmp declare -A cuda_url_map=() cuda_url_map[\"10.1\"]=",{"type":18,"tag":36,"props":289,"children":292},{"href":290,"rel":291},"https://developer.download.nvidia.cn/compute/cuda/10.1/Prod/local%5C_installers/cuda%5C_10.1.243%5C_418.87.00%5C_linux.run",[40],[293],{"type":24,"value":294},"https://developer.download.nvidia.cn/compute/cuda/10.1/Prod/local\\_installers/cuda\\_10.1.243\\_418.87.00\\_linux.run",{"type":24,"value":296}," cuda_url_map[\"11.1\"]=",{"type":18,"tag":36,"props":298,"children":301},{"href":299,"rel":300},"https://developer.download.nvidia.cn/compute/cuda/11.1.1/local%5C_installers/cuda%5C_11.1.1%5C_455.32.00%5C_linux.run",[40],[302],{"type":24,"value":303},"https://developer.download.nvidia.cn/compute/cuda/11.1.1/local\\_installers/cuda\\_11.1.1\\_455.32.00\\_linux.run",{"type":24,"value":305}," cuda_url=${cuda_url_map[$CUDA_VERSION]} wget $cuda_url sudo sh ${cuda_url##*/} --silent --toolkit cd - sudo apt-key adv --fetch-keys ",{"type":18,"tag":36,"props":307,"children":310},{"href":308,"rel":309},"https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86%5C_64/7fa2af80.pub",[40],[311],{"type":24,"value":312},"https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86\\_64/7fa2af80.pub",{"type":24,"value":314}," sudo add-apt-repository \"deb ",{"type":18,"tag":36,"props":316,"children":319},{"href":317,"rel":318},"https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86%5C_64/",[40],[320],{"type":24,"value":321},"https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu1804/x86\\_64/",{"type":24,"value":323}," /\" sudo add-apt-repository \"deb ",{"type":18,"tag":36,"props":325,"children":328},{"href":326,"rel":327},"https://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu1804/x86%5C_64/",[40],[329],{"type":24,"value":330},"https://developer.download.nvidia.cn/compute/machine-learning/repos/ubuntu1804/x86\\_64/",{"type":24,"value":332}," /\" sudo apt-get update declare -A cudnn_name_map=() cudnn_name_map[\"10.1\"]=\"libcudnn7=7.6.5.32-1+cuda10.1 libcudnn7-dev=7.6.5.32-1+cuda10.1\" cudnn_name_map[\"11.1\"]=\"libcudnn8=8.0.4.30-1+cuda11.1 libcudnn8-dev=8.0.4.30-1+cuda11.1\" sudo apt-get install --no-install-recommends ${cudnn_name_map[$CUDA_VERSION]} -y",{"type":18,"tag":26,"props":334,"children":335},{},[336],{"type":24,"value":337},"解析：下载CUDA和cuDNN并安装",{"type":18,"tag":26,"props":339,"children":340},{},[341],{"type":24,"value":255},{"type":18,"tag":26,"props":343,"children":344},{},[345],{"type":24,"value":346},"sudo apt-get install curl make gcc-7 libgmp-dev linux-headers-\"$(uname -r)\" -y",{"type":18,"tag":26,"props":348,"children":349},{},[350],{"type":24,"value":351},"解析：安装gcc gmp",{"type":18,"tag":26,"props":353,"children":354},{},[355],{"type":24,"value":255},{"type":18,"tag":26,"props":357,"children":358},{},[359],{"type":24,"value":360},"set +e && source ~/.bashrc set -e add_env PATH /usr/local/cuda/bin add_env LD_LIBRARY_PATH /usr/local/cuda/lib64 add_env LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu set +e && source ~/.bashrc",{"type":18,"tag":26,"props":362,"children":363},{},[364],{"type":24,"value":365},"解析：添加cuda到环境变量",{"type":18,"tag":26,"props":367,"children":368},{},[369,371,377],{"type":24,"value":370},"if [[ X\"$OPENMPI\" == \"Xon\" ]]; then echo \"installing openmpi\" cd /tmp curl -O ",{"type":18,"tag":36,"props":372,"children":375},{"href":373,"rel":374},"https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.3.tar.gz",[40],[376],{"type":24,"value":373},{"type":24,"value":378}," tar xzf openmpi-4.0.3.tar.gz cd openmpi-4.0.3 ./configure --prefix=/usr/local/openmpi-4.0.3 make sudo make install add_env PATH /usr/local/openmpi-4.0.3/bin add_env LD_LIBRARY_PATH /usr/local/openmpi-4.0.3/lib fi",{"type":18,"tag":26,"props":380,"children":381},{},[382],{"type":24,"value":383},"若是OPENMPI=on就是安装mpirun",{"type":18,"tag":26,"props":385,"children":386},{},[387],{"type":24,"value":388},"arch=`uname -m`",{"type":18,"tag":26,"props":390,"children":391},{},[392,394,401,403],{"type":24,"value":393},"python -m pip install ",{"type":18,"tag":36,"props":395,"children":398},{"href":396,"rel":397},"https://ms-release.obs.cn-north-4.myhuaweicloud.com/$%7BMINDSPORE%5C_VERSION%7D/MindSpore/gpu/$%7Barch%7D/$%7Bcuda%5C_name%7D/mindspore%5C_gpu-$%7Bversion%5C_map%5C%5B%22$PYTHON%5C_VERSION%22%5C%5D%7D-linux%5C_$%7Barch%7D.whl",[40],[399],{"type":24,"value":400},"https://ms-release.obs.cn-north-4.myhuaweicloud.com/${MINDSPORE\\_VERSION}/MindSpore/gpu/${arch}/${cuda\\_name}/mindspore\\_gpu-${version\\_map\\[\"$PYTHON\\_VERSION\"\\]}-linux\\_${arch}.whl",{"type":24,"value":402}," --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i ",{"type":18,"tag":36,"props":404,"children":406},{"href":263,"rel":405},[40],[407],{"type":24,"value":263},{"type":18,"tag":26,"props":409,"children":410},{},[411],{"type":24,"value":412},"安装匹配的whl包",{"type":18,"tag":26,"props":414,"children":415},{},[416],{"type":18,"tag":52,"props":417,"children":419},{"alt":7,"src":418},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2024/08/16/20aa294d29ba4f47b7c7093cc73c3572.png",[],{"type":18,"tag":26,"props":421,"children":422},{},[423],{"type":24,"value":424},"最后安装和执行成功",{"title":7,"searchDepth":426,"depth":426,"links":427},4,[],"markdown","content:technology-blogs:zh:3268.md","content","technology-blogs/zh/3268.md","technology-blogs/zh/3268","md",1776506128355]