From 0846eb401e29705aa7148d2a932ca5eab8092aaa Mon Sep 17 00:00:00 2001 From: huafengchun Date: Fri, 31 May 2024 11:44:58 +0800 Subject: [PATCH] Add docker selection --- _static/actions.js | 192 ++++++++++++++++++++++++++++---------- _static/package_info.js | 56 ++++++++--- sources/quick_install.rst | 30 +++++- 3 files changed, 213 insertions(+), 65 deletions(-) diff --git a/_static/actions.js b/_static/actions.js index 7e1d6b2..cfe55a9 100644 --- a/_static/actions.js +++ b/_static/actions.js @@ -5,31 +5,132 @@ $(document).ready(function () { }); } - var cann_version_select = $('#cann-version'); - $.update_version_list = function () { - var npu_item = $('#row-npu').find(".selected"); - var npu_type = npu_item.attr("id").split("-")[1]; + $.get_options = function () { + var options = {}; + $('#col-values').children().each(function () { + var elem = $(this).find(".selected").each(function () { + var id = $(this).attr("id").split("-"); + var category = id[0]; + var value = id[1]; + if (value == "version") { + if (category == "cann") + value = $(this).val(); + else + value = $(this).data('version'); + } + options[category] = value; + }); + }); + return options; + } + + $.update_os_verions = function () { + $("#row-os_version").find("div").not(":first").remove(); + var options = $.get_options(); + // update os_versions + var versions = os_versions[options['os']]; + var version_length = versions.length; + for (var i = 0; i < version_length; i++) { + var version = versions[i]; + $('#row-os_version').append('
' + version + '
'); + } + $("#row-os_version div:last-child").addClass("selected"); + } + + $.update_python_versions = function () { + $("#row-python_version").find("div").not(":first").remove(); + // update python_versions + var versions = python_versions; + var version_length = versions.length; + for (var i = 0; i < version_length; i++) { + var version = versions[i]; + $('#row-python_version').append('
' + version + '
'); + } + $("#row-python_version div:last-child").addClass("selected"); + } + + $.change_options_visible = function () { + var options = $.get_options(); + if (options['install_type'] == 'direct') { + $("#header-os_version").hide(); + $("#header-python_version").hide(); + $("#row-os_version").hide(); + $("#row-python_version").hide(); + } else { + $("#header-os_version").show(); + $("#header-python_version").show(); + $("#row-os_version").show(); + $("#row-python_version").show(); + } + } + + $has_key = function (obj, path) { + const keys = path.split('|'); + for (let key of keys) { + if (!obj || !obj.hasOwnProperty(key)) { + return false; + } + obj = obj[key]; + } + return true; + } + + $.update_cann_versions = function () { + // reset table. + var cann_version_select = $('#cann-version'); cann_version_select.empty(); cann_version_select.append(new Option("Select CANN Version", "na")); - $.each(package_info, function (key, value) { - if (npu_type in value) - cann_version_select.append(new Option("CANN: " + key, key)); - }); $.reset_selection(cann_version_select); $('#driver-version').text("Driver"); $('#firmware-version').text("Firmware"); + + var options = $.get_options(); + // not using docker. + if (options['install_type'] == "direct") { + // update select list. + $.each(package_info, function (key, value) { + if (options['npu'] in value) + cann_version_select.append(new Option("CANN: " + key, key)); + }); + } else { + $.each(package_info, function (key, value) { + // not all version has a docker image. + var find_key = options['npu'] + "|docker|" + options['os'] + "|" + options['os_version'] + "|" + options['python_version']; + if ($has_key(value, find_key)) { + cann_version_select.append(new Option("CANN: " + key, key)); + } + }); + } + cann_version_select.trigger('change'); + } - $.update_version_list(); + $.update_os_verions(); + $.update_python_versions(); + $.change_options_visible(); + $.update_cann_versions(); $("#col-values").on("click", ".values-element", function () { - fields = $(this).attr("id").split("-"); - if (fields[1] == "version") + id = $(this).attr("id"); + fields = id.split("-"); + if (fields[1] == "cann_version") return; + $.reset_selection($(this)); $(this).addClass("selected"); - $.update_version_list(); - $.gen_content($(this)); + + // if os changed, update os version. + if (fields[0] == "os") { + $.update_os_verions(); + } + + // if install type changed, update options visible. + if (fields[0] == "install_type") { + $.change_options_visible(); + } + + // update_cann_version if any option changed. + $.update_cann_versions(); }); $("#col-values").on("change", "select", function () { @@ -43,21 +144,18 @@ $(document).ready(function () { $('#driver-version').addClass("selected"); $('#firmware-version').addClass("selected"); - var npu_item = $('#row-npu').find(".selected"); - var npu_type = npu_item.attr("id").split("-")[1]; - var cann_version = $(this).val(); - var driver_version = package_info[cann_version][npu_type].driver_version; - var firmware_version = package_info[cann_version][npu_type].firmware_version; + var options = $.get_options(); + var driver_version = package_info[options['cann']][options['npu']].driver_version; + var firmware_version = package_info[options['cann']][options['npu']].firmware_version; $('#driver-version').text("Driver: " + driver_version); $('#driver-version').data("version", driver_version); $('#firmware-version').text("Firmware: " + firmware_version); $('#firmware-version').data("version", firmware_version); } - $.gen_content($(this)); + $.gen_content(); }); - - $.gen_content = function (elem) { + $.gen_content = function () { // instructions need all options selected. if ($('#cann-version').val() != "na") { $('#install-instructions').show(); @@ -66,21 +164,7 @@ $(document).ready(function () { return } - var options = {}; - elem.parent().parent().children().each(function () { - var elem = $(this).find(".selected").each(function () { - var id = $(this).attr("id").split("-"); - var category = id[0]; - var value = id[1]; - if (value == "version") { - if (category == "cann") - value = $(this).val(); - else - value = $(this).data('version'); - } - options[category] = value; - }); - }); + var options = $.get_options(); // install os dependency. if (options['os'] == 'ubuntu') { @@ -103,25 +187,35 @@ $(document).ready(function () { parts = cann_url.split("/"); var cann_name = parts[parts.length - 1]; - // download and install driver $('#install_drvier').html('wget "' + driver_url + '"
sudo sh ' + driver_name + ' --full --install-for-all'); // download and install firmware $('#install_firmware').html('wget "' + firmware_url + '"
sudo sh ' + firmware_name + ' --full'); - // download and install cann - $('#install_cann').html('wget "' + cann_url + '"
sh ' + cann_name + ' --install'); - - if (kernel_url == null) { - $('#install_kernel_section').hide(); - } - else { - parts = kernel_url.split("/"); - var kernel_name = parts[parts.length - 1]; - $('#install_kernel_section').show(); - // download and install kernel - $('#install_kernel').html('wget "' + kernel_url + '"
sh ' + kernel_name + ' --install'); + if (options['install_type'] == 'direct') { + // download and install cann + $('#install_cann').html('wget "' + cann_url + '"
sh ' + cann_name + ' --install'); + + // download and install kernel if exist. + if (kernel_url == null) { + $('#install_kernel_section').hide(); + } + else { + parts = kernel_url.split("/"); + var kernel_name = parts[parts.length - 1]; + $('#install_kernel_section').show(); + // download and install kernel + $('#install_kernel').html('wget "' + kernel_url + '"
sh ' + kernel_name + ' --install'); + } + + $('#use_docker_section').hide(); + $('#install_cann_section').show(); + } else { + var docker_image = package_info[options['cann']][options['npu']]['docker'][options['os']][options['os_version']][options['python_version']]; + $('#use_docker').html('docker pull ' + docker_image); + $('#install_cann_section').hide(); + $('#use_docker_section').show(); } } }); diff --git a/_static/package_info.js b/_static/package_info.js index e51ddbe..4fcb760 100644 --- a/_static/package_info.js +++ b/_static/package_info.js @@ -16,6 +16,21 @@ const package_info = { }, aarch64: { driver_url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Ascend HDK/Ascend HDK 23.0.3/Ascend-hdk-910b-npu-driver_23.0.3_linux-aarch64.run', + }, + docker: { + ubuntu: { + '22.04': { + '3.8': 'dockerimage38', + '3.9': 'dockerimage39' + } + }, + openeuler: { + '22.03': { + '3.8': 'dockerimage38', + '3.9': 'dockerimage39', + '3.10': 'dockerimage310' + } + } } }, '310p': { @@ -31,7 +46,7 @@ const package_info = { } } }, - '8.0.RC2.alpha001': { + '8.0.RC2.alpha001': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL V100R001C18B800TP015/Ascend-cann-toolkit_8.0.RC2.alpha001_linux-x86_64.run' }, @@ -63,7 +78,7 @@ const package_info = { } } }, - '8.0.RC1.beta1': { + '8.0.RC1.beta1': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN 8.0.RC1/Ascend-cann-toolkit_8.0.RC1_linux-x86_64.run' }, @@ -83,7 +98,7 @@ const package_info = { } } }, - '8.0.RC1.alpha003': { + '8.0.RC1.alpha003': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL V100R001C17SPC703/Ascend-cann-toolkit_8.0.RC1.alpha003_linux-x86_64.run' }, @@ -115,7 +130,7 @@ const package_info = { } } }, - '8.0.RC1.alpha002': { + '8.0.RC1.alpha002': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL V100R001C17SPC702/Ascend-cann-toolkit_8.0.RC1.alpha002_linux-x86_64.run' }, @@ -147,7 +162,7 @@ const package_info = { } } }, - '8.0.RC1.alpha001': { + '8.0.RC1.alpha001': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL V100R001C17SPC701/Ascend-cann-toolkit_8.0.RC1.alpha001_linux-x86_64.run' }, @@ -179,7 +194,7 @@ const package_info = { } } }, - '7.0.0.beta1': { + '7.0.0.beta1': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN 7.0.0/Ascend-cann-toolkit_7.0.0_linux-x86_64.run' }, @@ -211,7 +226,7 @@ const package_info = { } } }, - '7.0.0.alpha003': { + '7.0.0.alpha003': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL V100R001C15SPC703/Ascend-cann-toolkit_7.0.0.alpha003_linux-x86_64.run' }, @@ -243,7 +258,7 @@ const package_info = { } } }, - '7.0.0.alpha002': { + '7.0.0.alpha002': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL V100R001C15SPC702/Ascend-cann-toolkit_7.0.0.alpha002_linux-x86_64.run' }, @@ -275,7 +290,7 @@ const package_info = { } } }, - '7.0.RC1.beta1': { + '7.0.RC1.beta1': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN 7.0.RC1/Ascend-cann-toolkit_7.0.RC1_linux-x86_64.run' }, @@ -307,7 +322,7 @@ const package_info = { } } }, - '6.3.RC2.alpha005': { + '6.3.RC2.alpha005': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN 6.3.RC2/Ascend-cann-toolkit_6.3.RC2_linux-x86_64.run' }, @@ -327,7 +342,7 @@ const package_info = { } } }, - '6.3.RC1.alpha003': { + '6.3.RC1.alpha003': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN 6.3.RC1/Ascend-cann-toolkit_6.3.RC1_linux-x86_64.run' }, @@ -346,7 +361,7 @@ const package_info = { } } }, - '6.0.RC1.alpha005': { + '6.0.RC1.alpha005': { x86_64: { url: 'https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN6.0.RC1/Ascend-cann-toolkit_6.0.RC1_linux-x86_64.run' }, @@ -366,3 +381,20 @@ const package_info = { } } }; + +const os_versions = { + ubuntu: [ + '20.04', + '22.04' + ], + openeuler: [ + '20.03', + '22.03' + ] +}; + +const python_versions = [ + '3.8', + '3.9', + '3.10' +]; \ No newline at end of file diff --git a/sources/quick_install.rst b/sources/quick_install.rst index ea06c21..598f2a9 100644 --- a/sources/quick_install.rst +++ b/sources/quick_install.rst @@ -38,9 +38,12 @@ Python 3.8, 3.9, 3.10
操作系统
+
操作系统版本
+
安装方式
CPU架构
NPU型号
-
版本选择
+
Python版本
+
昇腾套件版本
@@ -48,6 +51,14 @@ Python 3.8, 3.9, 3.10
openEuler
Ubuntu
+
+
操作系统版本
+
+
+
安装方式
+
直接安装
+
Docker
+
CPU架构
x86-64
@@ -58,8 +69,11 @@ Python 3.8, 3.9, 3.10
Atlas 300T A2 训练卡
Atlas 300I Pro 推理卡
-
-
版本选择
+
+
Python版本
+
+
+
昇腾套件版本
@@ -102,7 +116,7 @@ Python 3.8, 3.9, 3.10
-
+

2.3 安装CANN

安装python依赖

@@ -131,6 +145,14 @@ Python 3.8, 3.9, 3.10
+
+

2.3 使用Docker镜像

+
+
+

+                            
+
+