Skip to content

Commit

Permalink
Add pytorch docker and add copy butten
Browse files Browse the repository at this point in the history
  • Loading branch information
hipudding authored and FFFrog committed Jun 13, 2024
1 parent 620fb2f commit 68d2ebc
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 89 deletions.
10 changes: 5 additions & 5 deletions _static/ascend_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ $(document).ready(function () {
var cann_name = parts[parts.length - 1];

// download and install driver
$('#install_drvier').html('wget "' + driver_url + '"<br>sudo sh ' + driver_name + ' --full --install-for-all');
$('#codecell5').html('wget "' + driver_url + '"<br>sudo sh ' + driver_name + ' --full --install-for-all');

// download and install firmware
$('#install_firmware').html('wget "' + firmware_url + '"<br>sudo sh ' + firmware_name + ' --full');
$('#codecell6').html('wget "' + firmware_url + '"<br>sudo sh ' + firmware_name + ' --full');

if (options['install_type'] === 'direct') {
// download and install cann
$('#install_cann').html('wget "' + cann_url + '"<br>sh ' + cann_name + ' --install');
$('#codecell8').html('wget "' + cann_url + '"<br>sh ' + cann_name + ' --install');

// download and install kernel if exist.
if (kernel_url == null) {
Expand All @@ -207,7 +207,7 @@ $(document).ready(function () {
var kernel_name = parts[parts.length - 1];
$('#install_kernel_section').show();
// download and install kernel
$('#install_kernel').html('wget "' + kernel_url + '"<br>sh ' + kernel_name + ' --install');
$('#codecell9').html('wget "' + kernel_url + '"<br>sh ' + kernel_name + ' --install');
}

$('#use_docker_section').hide();
Expand All @@ -231,7 +231,7 @@ docker run \\
-it ${docker_images[i]} bash
`;

$('#use_docker').html(dockerCommand.trim());
$('#codecell11').html(dockerCommand.trim());
break;
}
}
Expand Down
9 changes: 6 additions & 3 deletions _static/package_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,19 @@ const pytorch_versions = {
'2.2.0': {
torch_npu: '2.2.0',
npu_branch: 'v2.2.0-6.0.rc1',
cann: 'CANN 8.0.RC1'
cann: 'CANN 8.0.RC1',
docker: 'cosdt/torch:2.2.0'
},
'2.1.0': {
torch_npu: '2.1.0.post3',
npu_branch: 'v2.1.0-6.0.rc1',
cann: 'CANN 8.0.RC1'
cann: 'CANN 8.0.RC1',
docker: 'cosdt/torch:2.1.0'
},
'2.0.1': {
torch_npu: '2.0.1.post1',
npu_branch: 'v2.1.0-5.0.0',
cann: 'CANN 7.0.0'
cann: 'CANN 7.0.0',
docker: 'cosdt/torch:2.0.1'
}
}
49 changes: 35 additions & 14 deletions _static/pytorch_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ $(document).ready(function () {
var id = $(this).attr("id").split("-");
var category = id[0];
var value = id[1];
if(category == 'pytorch')
options[category] = value;
else
if(category == 'cann' || category == 'pytorch_npu')
options[category] = $(this).text();
else
options[category] = value;
});
});
return options;
Expand All @@ -24,7 +24,7 @@ $(document).ready(function () {
$.update_table = function () {
var options = $.get_options();
var pytorch_version = options['pytorch'];
match_versions = pytorch_versions[pytorch_version];
var match_versions = pytorch_versions[pytorch_version];
$("#pytorch_npu-version").text(match_versions['torch_npu']);
$("#cann-version").text(match_versions['cann']);
}
Expand All @@ -44,27 +44,48 @@ $(document).ready(function () {

$.gen_content = function () {
var options = $.get_options();
if (options['install_type'] == "pip") {
if (options['install_type'] == "docker") {
var pytorch_version = options['pytorch'];
var match_versions = pytorch_versions[pytorch_version];
var dockerCommand = `
docker run \\
--name cann_container \\
--device /dev/davinci1 \\
--device /dev/davinci_manager \\
--device /dev/devmm_svm \\
--device /dev/hisi_hdc \\
-v /usr/local/dcmi:/usr/local/dcmi \\
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \\
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \\
-v /etc/ascend_install.info:/etc/ascend_install.info \\
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \\
-it ${match_versions['docker']} bash
`;

$('#codecell0').html(dockerCommand);
$('#install-pytorch-source-section').hide();
$('#install-pytorch-pip-section').hide();
$('#install-pytorch-docker-section').show();
} else if (options['install_type'] == "pip") {
$('#codecell1').html("# install torch<br>");
if(options['arch'] == "aarch64")
$('#install-pytorch-pip').html("pip3 install torch==" + options['pytorch']);
$('#codecell1').append("pip3 install torch==" + options['pytorch']);
else
$('#install-pytorch-pip').html("pip3 install torch=="+options['pytorch']+"+cpu --index-url https://download.pytorch.org/whl/cpu");
$('#codecell1').append("pip3 install torch=="+options['pytorch']+"+cpu --index-url https://download.pytorch.org/whl/cpu");

$("#install-pytorch_npu-pip").html("pip3 install torch-npu==" + options['pytorch_npu']);
$("#codecell1").append("<br><br># install torch-npu<br>pip3 install torch-npu==" + options['pytorch_npu']);

$('#install-pytorch-source-section').hide();
$('#install-pytorch_npu-source-section').hide();
$('#install-pytorch-docker-section').hide();
$('#install-pytorch-pip-section').show();
$('#install-pytorch_npu-pip-section').show();
} else {
$("#install-pytorch-source-build").html("# install requirements<br>conda install cmake ninja<br><br># get source<br>git clone -b "+options['pytorch']+" --recursive https://github.com/pytorch/pytorch<br>cd pytorch<br>git submodule update --init --recursive<br><br># install PyTorch<br>pip install -r requirements.txt<br>export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-\"$(dirname $(which conda))/../\"}<br>python setup.py develop");
$("#codecell2").html("# install requirements<br>conda install cmake ninja<br><br># get torch source<br>git clone -b "+options['pytorch']+" --recursive https://github.com/pytorch/pytorch<br>cd pytorch<br>git submodule update --init --recursive<br><br># install torch<br>pip install -r requirements.txt<br>export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-\"$(dirname $(which conda))/../\"}<br>python setup.py develop");

$('#install-pytorch_npu-source-build').html("# get source<br>git clone https://github.com/ascend/pytorch.git -b "+options['pytorch_npu']+" --depth 1 pytorch_npu<br>cd pytorch_npu<br><br>#install pytorch_npu<br>bash ci/build.sh --python=$(python --version 2>&1 | awk '{print $2}' | cut -d '.' -f 1,2)");
$('#codecell2').append("<br><br># get torch-npu source<br>git clone https://github.com/ascend/pytorch.git -b "+options['pytorch_npu']+" --depth 1 pytorch_npu<br>cd pytorch_npu<br><br>#install torch-npu<br>bash ci/build.sh --python=$(python --version 2>&1 | awk '{print $2}' | cut -d '.' -f 1,2)");

$('#install-pytorch-pip-section').hide();
$('#install-pytorch_npu-pip-section').hide();
$('#install-pytorch-docker-section').hide();
$('#install-pytorch-source-section').show();
$('#install-pytorch_npu-source-section').show();
}

}
Expand Down
3 changes: 2 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
extensions = [
'sphinx.ext.autodoc',
'recommonmark',
'sphinxext.remoteliteralinclude'
'sphinxext.remoteliteralinclude',
'sphinx_copybutton'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Sphinx
sphinx-autobuild
sphinx-rtd-theme
recommonmark
sphinxext-remoteliteralinclude
sphinxext-remoteliteralinclude
sphinx-copybutton
42 changes: 25 additions & 17 deletions sources/ascend/quick_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@

跟随指导,在您的机器上快速安装昇腾环境。

1. 系统要求
系统要求
----------------
1.1 前置检查
^^^^^^^^^^^^^
确认昇腾AI处理器已经安装妥当
::

.. code-block:: bash
lspci | grep 'Processing accelerators'
确认操作系统架构及版本
::

.. code-block:: bash
uname -m && cat /etc/*release
Expand All @@ -28,7 +30,7 @@ Python 3.8, 3.9, 3.10
======== ========================================


2. 环境安装
环境安装
------------------
根据您的需求,选择合适的软件包版本:

Expand Down Expand Up @@ -102,14 +104,14 @@ Python 3.8, 3.9, 3.10
<p><b>下载并安装</b></p>
<div class="highlight-default notranslate">
<div class="highlight">
<pre id="install_drvier"></pre>
<pre></pre>
</div>
</div>
<section>
<h3>2.2 安装固件</h3>
<div class="highlight-default notranslate">
<div class="highlight">
<pre id="install_firmware"></pre>
<pre></pre>
</div>
</div>
</section>
Expand All @@ -124,14 +126,14 @@ Python 3.8, 3.9, 3.10
<p><b>下载并安装</b></p>
<div class="highlight-default notranslate">
<div class="highlight">
<pre id="install_cann"></pre>
<pre></pre>
</div>
</div>
<div id="install_kernel_section">
<p><b>安装算子包(可选)</b></p>
<div class="highlight-default notranslate">
<div class="highlight">
<pre id="install_kernel"></pre>
<pre></pre>
</div>
</div>
</div>
Expand All @@ -149,7 +151,7 @@ Python 3.8, 3.9, 3.10
</div>
<div class="highlight-default notranslate">
<div class="highlight">
<pre id="use_docker"></pre>
<pre></pre>
</div>
</div>
</section>
Expand All @@ -158,13 +160,14 @@ Python 3.8, 3.9, 3.10
</div>


3. 验证安装(可选)
验证安装(可选)
---------------------
**验证驱动**

确认您的驱动是否安装成功,可以通过以下命令验证:``npu-smi info``
,若出现以下回显信息,说明驱动安装成功。
::

.. code-block:: bash
+-------------------------------------------------------------------------------------------+
| npu-smi 23.0.2 Version: 23.0.2 |
Expand Down Expand Up @@ -200,31 +203,36 @@ Python 3.8, 3.9, 3.10
**验证固件**

安装固件后,若系统出现如下关键回显信息,表示固件安装成功。
::

.. code-block:: bash
Firmware package installed successfully!
**验证CANN-toolkit**

安装CANN-toolkit后,若系统出现以下关键回显信息,表示CANN-toolkit安装成功。
::

.. code-block:: bash
[INFO] Ascend-cann-toolkit install success
4. 卸载
卸载
----------
**卸载驱动**
::

.. code-block:: bash
sudo /usr/local/Ascend/firmware/script/uninstall.sh
**卸载固件**
::

.. code-block:: bash
sudo /usr/local/Ascend/driver/script/uninstall.sh
**卸载CANN-toolkit**
::

.. code-block:: bash
<path>/ascend-toolkit/<cann_version>/{arch}-linux/script/uninstall.sh
8 changes: 5 additions & 3 deletions sources/pytorch/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

在运行下述示例之前,需要您已经安装了PyTorch-NPU环境,有关环境安装,请参考 :doc:`./install`

1. 数据并行
数据并行
-----------------------

PyTorch的数据并行主要分为以下几种:DP、DDP以及FSDP(HSDP变种),接下来将简单描述在Ascend NPU场景下如何实现上述数据并行。

DDP:
DDP
^^^^^^

.. code-block:: python
:linenos:
Expand Down Expand Up @@ -82,7 +83,8 @@ DDP:
if __name__ == "__main__":
main()
FSDP:
FSDP
^^^^^^

.. code-block:: python
:linenos:
Expand Down
Loading

0 comments on commit 68d2ebc

Please sign in to comment.