{"id":660,"date":"2026-08-28T09:28:37","date_gmt":"2026-08-28T01:28:37","guid":{"rendered":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/2026\/08\/28\/ascend-pytorch-torch-npu-build\/"},"modified":"2026-08-28T09:55:57","modified_gmt":"2026-08-28T01:55:57","slug":"ascend-pytorch-torch-npu-build","status":"publish","type":"post","link":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/2026\/08\/28\/ascend-pytorch-torch-npu-build\/","title":{"rendered":"Ascend for PyTorch\u6e90\u7801\u5b89\u88c5\u4e0e\u6784\u5efa\u5b9e\u6218"},"content":{"rendered":"<p class=\"cp-lead\">\u4e00\u6b21\u5728\u534e\u4e3a HiDevLab\uff08CANN 9.0.0 + openEuler \u955c\u50cf\uff09\u4e0a\u4ece\u6e90\u7801\u7f16\u8bd1 torch_npu \u7684\u5b8c\u6574\u5b9e\u6218\u8bb0\u5f55\uff1a\u4ece\u6e90\u7801\u83b7\u53d6\u3001\u4fee\u6539 op_api \u65e5\u5fd7\uff0c\u5230 GCC 11.2.0 \u4e0e CMake 3.18.4 \u7684\u8fde\u73af\u8e29\u5751\u4fee\u590d\uff0c\u518d\u5230 Whl \u6253\u5305\u5b89\u88c5\u4e0e NPU \u529f\u80fd\u9a8c\u8bc1\u3002<\/p>\n<blockquote><p>\u73af\u5883\uff1a\u534e\u4e3a HiDevLab \u5728\u7ebf IDE<br \/>CANN 9.0.0 + openEuler \u955c\u50cf\uff08aarch64\uff09<br \/>torch_npu v2.7.1-26.0.0 \/ torch 2.7.0<\/p><\/blockquote>\n<hr>\n<hr>\n<h2>\u4e00\u3001\u73af\u5883\u4e0e\u955c\u50cf\u51c6\u5907<\/h2>\n<p><strong>\u5728<a href=\"https:\/\/hidevlab.huawei.com\/home\" target=\"_blank\" rel=\"noopener\">HiDevLab<\/a>\u521b\u5efa\u4e00\u4e2aCANN9.0.0-OpenEuler\u7684\u955c\u50cf\u3002<\/strong><\/p>\n<p>\u6ce8\uff1a\u8fd9\u4e2a\u955c\u50cf\u7684gcc\u7248\u672c\u9ed8\u8ba4\u53ea\u80fd\u7f16\u8bd12.7.1\u5206\u652f\u3002<\/p>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image1.png\" alt=\"image1.png\" width=\"1358\" height=\"657\" loading=\"lazy\"><\/figure>\n<hr>\n<h2>\u4e8c\u3001\u83b7\u53d6 torch_npu \u6e90\u7801<\/h2>\n<p><strong>\u8fdb\u5165\u5728\u7ebfIDE\u540e\uff0cclone <a href=\"https:\/\/atomgit.com\/Ascend\/pytorch\" target=\"_blank\" rel=\"noopener\">torch_npu<\/a>\u4ee3\u7801\uff0ccheckout\u5230v2.7.1-26.0.0\u5206\u652f<\/strong><\/p>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image2.png\" alt=\"image2.png\" width=\"1360\" height=\"248\" loading=\"lazy\"><\/figure>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image3.png\" alt=\"image3.png\" width=\"1242\" height=\"599\" loading=\"lazy\"><\/figure>\n<p>\u4e0b\u8f7dtorch_npu\u6e90\u7801<\/p>\n<pre class=\"cp-code\"><code># git clone https:\/\/gitcode.com\/Ascend\/pytorch.git -b v2.7.1-26.0.0 --depth 1<\/code><\/pre>\n<hr>\n<h2>\u4e09\u3001\u4fee\u6539 CloneKernelOpApi.cpp \u589e\u52a0\u65e5\u5fd7<\/h2>\n<p><strong>\u5728CloneKernelOpApi.cpp\u4e2d\u589e\u52a0\u4e00\u884c\u65e5\u5fd7<\/strong><\/p>\n<pre class=\"cp-code\"><code># cd workspace\/pytorch\/torch_npu\/csrc\/aten\/ops\/op_api\/\r\n# cp CloneKernelOpApi.cpp CloneKernelOpApi.cpp.backup\r\n# vim CloneKernelOpApi.cpp<\/code><\/pre>\n<p>\u589e\u52a0antares-test\u8f93\u51fa<\/p>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image4.png\" alt=\"image4.png\" width=\"1178\" height=\"673\" loading=\"lazy\"><\/figure>\n<hr>\n<h2>\u56db\u3001\u7f16\u8bd1\u73af\u5883\u642d\u5efa\uff08GCC \/ CMake\uff09<\/h2>\n<p><strong>\u5b8c\u6210torch_npu\u7f16\u8bd1\uff0c\u5e76\u5b89\u88c5<\/strong><\/p>\n<pre class=\"cp-code\"><code># yum install -y patch libjpeg-turbo-devel dos2unix openblas git<\/code><\/pre>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image5.png\" alt=\"image5.png\" width=\"1111\" height=\"353\" loading=\"lazy\"><\/figure>\n<p class=\"cp-subhead\"><strong>\u5b89\u88c5 GCC 11.2.0<\/strong><\/p>\n<pre class=\"cp-code\"><code># wget https:\/\/repo.huaweicloud.com\/gnu\/gcc\/gcc-11.2.0\/gcc-11.2.0.tar.gz\r\n# rm -rf \/tmp\/*\r\n# yum install bzip2\r\n# tar -zxvf gcc-11.2.0.tar.gz\r\n# cd gcc-11.2.0\r\n# .\/contrib\/download_prerequisites<\/code><\/pre>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image6.png\" alt=\"image6.png\" width=\"1102\" height=\"201\" loading=\"lazy\"><\/figure>\n<pre class=\"cp-code\"><code># .\/configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=\/usr\/local\/gcc11.2.0<\/code><\/pre>\n<p>\u901a\u8fc7grep -w processor \/proc\/cpuinfo|wc -l\u67e5\u770bcpu\u6570\uff0c\u793a\u4f8b\u4e3a15\uff0c\u7528\u6237\u53ef\u81ea\u884c\u8bbe\u7f6e\u76f8\u5e94\u53c2\u6570\u3002<\/p>\n<p>\u5b9e\u9645\u663e\u793aCPU\u6570\u91cf\u4e3a640<\/p>\n<pre class=\"cp-code\"><code># make -j500<\/code><\/pre>\n<p>\u62a5\u9519\uff1a<\/p>\n<pre class=\"cp-code cp-error\"><code>make[3]: Leaving directory '\/workspace\/pytorch\/gcc-11.2.0\/host-aarch64-unknown-linux-gnu\/gcc'\r\nmake[2]: *** [Makefile:4788: all-stage1-gcc] Error 2\r\nmake[2]: Leaving directory '\/workspace\/pytorch\/gcc-11.2.0'\r\nmake[1]: *** [Makefile:27497: stage1-bubble] Error 2\r\nmake[1]: Leaving directory '\/workspace\/pytorch\/gcc-11.2.0'\r\nmake: *** [Makefile:1009: all] Error 2<\/code><\/pre>\n<p>\u539f\u56e0\u662f\u7f3a\u5c11zlib\u5f00\u53d1\u7ec4\u4ef6<\/p>\n<pre class=\"cp-code\"><code># yum install -y zlib-devel\r\n# make -j500<\/code><\/pre>\n<p>\u62a5\u9519\uff1a<\/p>\n<pre class=\"cp-code cp-error\"><code>make[4]: Leaving directory '\/workspace\/pytorch\/gcc-11.2.0\/aarch64-unknown-linux-gnu\/libsanitizer\/sanitizer_common'\r\nmake[3]: *** [Makefile:531: all-recursive] Error 1\r\nmake[3]: Leaving directory '\/workspace\/pytorch\/gcc-11.2.0\/aarch64-unknown-linux-gnu\/libsanitizer'\r\nmake[2]: *** [Makefile:418: all] Error 2\r\nmake[2]: Leaving directory '\/workspace\/pytorch\/gcc-11.2.0\/aarch64-unknown-linux-gnu\/libsanitizer'\r\nmake[1]: *** [Makefile:21270: all-target-libsanitizer] Error 2\r\nmake[1]: Leaving directory '\/workspace\/pytorch\/gcc-11.2.0'\r\nmake: *** [Makefile:1011: all] Error 2<\/code><\/pre>\n<p>\u9700\u8981\u7981\u7528libsanitizer<\/p>\n<pre class=\"cp-code\"><code># cd \/workspace\/pytorch\/gcc-11.2.0\r\n# make distclean\r\n# .\/configure --disable-bootstrap --enable-languages=c,c++ --disable-libsanitizer --prefix=\/usr\/local\/gcc-11.2.0\r\n# make -j500<\/code><\/pre>\n<p>\u6ce8\uff1a\u672c\u6b65\u9aa4\u8017\u65f6\u8f83\u957f<\/p>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image7.png\" alt=\"image7.png\" width=\"1043\" height=\"458\" loading=\"lazy\"><\/figure>\n<pre class=\"cp-code\"><code># make install<\/code><\/pre>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image8.png\" alt=\"image8.png\" width=\"862\" height=\"406\" loading=\"lazy\"><\/figure>\n<p class=\"cp-subhead\"><strong>\u914d\u7f6e GCC \u73af\u5883\u53d8\u91cf<\/strong><\/p>\n<pre class=\"cp-code\"><code>export LD_LIBRARY_PATH=\/usr\/local\/gcc-11.2.0\/lib64:${LD_LIBRARY_PATH}\r\nexport CC=\/usr\/local\/gcc-11.2.0\/bin\/gcc\r\nexport CXX=\/usr\/local\/gcc-11.2.0\/bin\/g++\r\nexport PATH=\/usr\/local\/gcc-11.2.0\/bin:${PATH}<\/code><\/pre>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image9.png\" alt=\"image9.png\" width=\"739\" height=\"103\" loading=\"lazy\"><\/figure>\n<p>\u5982\u679c\u4e0a\u8ff0\u64cd\u4f5c\u4e0d\u751f\u6548<\/p>\n<pre class=\"cp-code\"><code># mv \/usr\/bin\/gcc \/usr\/bin\/gcc.bak\r\n# mv \/usr\/bin\/g++ \/usr\/bin\/g++.bak\r\n# mv \/usr\/bin\/c++ \/usr\/bin\/c++.bak\r\n# mv \/usr\/bin\/cc \/usr\/bin\/cc.bak\r\n# ln -s \/usr\/local\/gcc-11.2.0\/bin\/gcc \/usr\/bin\/gcc\r\n# ln -s \/usr\/local\/gcc-11.2.0\/bin\/g++ \/usr\/bin\/g++\r\n# ln -s \/usr\/local\/gcc-11.2.0\/bin\/c++ \/usr\/bin\/c++\r\n# ln -s \/usr\/local\/gcc-11.2.0\/bin\/gcc \/usr\/bin\/cc<\/code><\/pre>\n<p class=\"cp-subhead\"><strong>\u5b89\u88c5 CMake 3.18.4<\/strong><\/p>\n<pre class=\"cp-code\"><code># wget https:\/\/cmake.org\/files\/v3.18\/cmake-3.18.4.tar.gz\r\n# tar -xf cmake-3.18.4.tar.gz\r\n# cd cmake-3.18.4\/\r\n# .\/configure --prefix=\/usr\/local\/cmake<\/code><\/pre>\n<p>\u62a5\u9519<\/p>\n<pre class=\"cp-code cp-error\"><code>CMake Error at Utilities\/cmcurl\/CMakeLists.txt:485 (message):\r\nCould not find OpenSSL.  Install an OpenSSL development package or\r\nconfigure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.\r\n-- Configuring incomplete, errors occurred!\r\nSee also \"\/workspace\/pytorch\/cmake-3.18.4\/CMakeFiles\/CMakeOutput.log\".\r\nSee also \"\/workspace\/pytorch\/cmake-3.18.4\/CMakeFiles\/CMakeError.log\".\r\n---------------------------------------------\r\nError when bootstrapping CMake:\r\nProblem while running initial CMake<\/code><\/pre>\n<p>\u9700\u8981\u5b89\u88c5openssl<\/p>\n<pre class=\"cp-code\"><code># yum install -y openssl-devel\r\n# .\/configure --prefix=\/usr\/local\/cmake\r\nmake -j500<\/code><\/pre>\n<p>\u62a5\u9519\uff1a<\/p>\n<pre class=\"cp-code cp-error\"><code>259 |   FSCONFIG_SET_PATH_EMPTY = 4,    \/* Set parameter, supplying an object by (empty) path *\/\r\n|   ^~~~~~~~~~~~~~~~~~~~~~~\r\n\/usr\/include\/linux\/mount.h:102:9: error: redeclaration of enumerator 'FSCONFIG_SET_FD'\r\n102 |         FSCONFIG_SET_FD         = 5,    \/* Set parameter, supplying an object by fd *\/\r\n|         ^~~~~~~~~~~~~~~\r\n\/usr\/local\/gcc-11.2.0\/lib\/gcc\/aarch64-unknown-linux-gnu\/11.2.0\/include-fixed\/sys\/mount.h:261:3: note: previous definition of 'FSCONFIG_SET_FD' with type 'enum fsconfig_command'\r\n261 |   FSCONFIG_SET_FD         = 5,    \/* Set parameter, supplying an object by fd *\/\r\n|   ^~~~~~~~~~~~~~~\r\n\/usr\/include\/linux\/mount.h:103:9: error: redeclaration of enumerator 'FSCONFIG_CMD_CREATE'\r\n103 |         FSCONFIG_CMD_CREATE     = 6,    \/* Create new or reuse existing superblock *\/\r\n|         ^~~~~~~~~~~~~~~~~~~\r\n\/usr\/local\/gcc-11.2.0\/lib\/gcc\/aarch64-unknown-linux-gnu\/11.2.0\/include-fixed\/sys\/mount.h:263:3: note: previous definition of 'FSCONFIG_CMD_CREATE' with type 'enum fsconfig_command'\r\n263 |   FSCONFIG_CMD_CREATE     = 6,    \/* Invoke superblock creation *\/\r\n|   ^~~~~~~~~~~~~~~~~~~\r\n\/usr\/include\/linux\/mount.h:104:9: error: redeclaration of enumerator 'FSCONFIG_CMD_RECONFIGURE'\r\n104 |         FSCONFIG_CMD_RECONFIGURE = 7,   \/* Invoke superblock reconfiguration *\/\r\n|         ^~~~~~~~~~~~~~~~~~~~~~~~\r\n\/usr\/local\/gcc-11.2.0\/lib\/gcc\/aarch64-unknown-linux-gnu\/11.2.0\/include-fixed\/sys\/mount.h:265:3: note: previous definition of 'FSCONFIG_CMD_RECONFIGURE' with type 'enum fsconfig_command'\r\n265 |   FSCONFIG_CMD_RECONFIGURE = 7,   \/* Invoke superblock reconfiguration *\/\r\n|   ^~~~~~~~~~~~~~~~~~~~~~~~\r\nIn file included from \/usr\/include\/linux\/fs.h:19,\r\nfrom \/workspace\/pytorch\/cmake-3.18.4\/Utilities\/cmlibarchive\/libarchive\/archive_read_disk_posix.c:56:\r\n\/usr\/include\/linux\/mount.h:131:8: error: redefinition of 'struct mount_attr'\r\n131 | struct mount_attr {\r\n|        ^~~~~~~~~~\r\nIn file included from \/workspace\/pytorch\/cmake-3.18.4\/Utilities\/cmlibarchive\/libarchive\/archive_read_disk_posix.c:38:\r\n\/usr\/local\/gcc-11.2.0\/lib\/gcc\/aarch64-unknown-linux-gnu\/11.2.0\/include-fixed\/sys\/mount.h:219:8: note: originally defined here\r\n219 | struct mount_attr\r\n|        ^~~~~~~~~~\r\nmake[2]: *** [Utilities\/cmlibarchive\/libarchive\/CMakeFiles\/cmlibarchive.dir\/build.make:433: Utilities\/cmlibarchive\/libarchive\/CMakeFiles\/cmlibarchive.dir\/archive_read_disk_posix.c.o] Error 1\r\nmake[1]: *** [CMakeFiles\/Makefile2:2162: Utilities\/cmlibarchive\/libarchive\/CMakeFiles\/cmlibarchive.dir\/all] Error 2\r\nmake: *** [Makefile:182: all] Error 2<\/code><\/pre>\n<p>\u539f\u56e0\u662fgcc 11.2.0 \u5b89\u88c5\u65f6\uff0cfixincludes \u673a\u5236\u4f1a\u628a&#8221;\u5f53\u65f6&#8221;\u7cfb\u7edf\u7684 sys\/mount.h \u590d\u5236\u4e00\u4efd&#8221;\u4fee\u590d\u7248&#8221;\u653e\u8fdb\u81ea\u5df1\u7684 include-fixed \u76ee\u5f55\uff1b<\/p>\n<p>\u800c\u5f53\u524d\u73af\u5883\u7684\u7cfb\u7edf\u5185\u6838\u5934\u6587\u4ef6\uff08\/usr\/include\/linux\/mount.h\uff09\u6bd4 gcc 11 \u53d1\u5e03\u65f6\u65b0\uff0c\u591a\u4e86 FSCONFIG_SET_STRING\u3001struct mount_attr \u7b49\u65b0\u5b9a\u4e49\u3002<\/p>\n<p>\u73b0\u5728\u7cfb\u7edf\u9ed8\u8ba4\u7f16\u8bd1\u5668\u662f gcc 11\uff0c\u7f16\u8bd1\u4efb\u4f55\u95f4\u63a5\u5305\u542b linux\/mount.h \u7684\u7a0b\u5e8f\uff08CMake \u7684 libarchive\u3001\u4e4b\u524d\u7684 libsanitizer \u90fd\u662f\uff09\u90fd\u4f1a\u649e\u4e0a\u8fd9\u4efd\u65e7\u5feb\u7167\u3002<\/p>\n<p>\u4fee\u590d\uff1a\u628a\u51b2\u7a81\u7684 include-fixed \u6587\u4ef6\u79fb\u8d70<\/p>\n<pre class=\"cp-code\"><code># cd \/usr\/local\/gcc-11.2.0\/lib\/gcc\/aarch64-unknown-linux-gnu\/11.2.0\/include-fixed\/\r\n# ls sys\/<\/code><\/pre>\n<p>\u628a\u51b2\u7a81\u7684 mount.h \u5907\u4efd\u79fb\u8d70\uff08\u4e0d\u8981\u76f4\u63a5\u5220\uff0c\u7559\u4e2a\u540e\u8def\uff09<\/p>\n<pre class=\"cp-code\"><code># mv sys\/mount.h sys\/mount.h.bak\r\n# make -j500\r\n# make install<\/code><\/pre>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image10.png\" alt=\"image10.png\" width=\"734\" height=\"196\" loading=\"lazy\"><\/figure>\n<pre class=\"cp-code\"><code># ln -s \/usr\/local\/cmake\/bin\/cmake \/usr\/bin\/cmake\r\n# cmake --version<\/code><\/pre>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image11.png\" alt=\"image11.png\" width=\"764\" height=\"151\" loading=\"lazy\"><\/figure>\n<hr>\n<h2>\u4e94\u3001\u7f16\u8bd1 torch_npu Whl \u5305\u5e76\u5b89\u88c5<\/h2>\n<p class=\"cp-subhead\"><strong>\u7f16\u8bd1\u751f\u6210 torch_npu Whl \u5b89\u88c5\u5305<\/strong><\/p>\n<pre class=\"cp-code\"><code># bash ci\/build.sh --python=3.10<\/code><\/pre>\n<p>\u62a5\u9519\uff1a<\/p>\n<pre class=\"cp-code cp-error\"><code>.\/ci\/build.sh: line 106: python3.10: command not found<\/code><\/pre>\n<p>\u5148\u786e\u8ba4pip\u6e90<\/p>\n<pre class=\"cp-code\"><code># cd ~\/.pip\r\n# vim pip.conf\r\n[global]\r\n#\u4ee5\u534e\u4e3a\u6e90\u4e3a\u4f8b\uff0c\u8bf7\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u66ff\u6362\u3002\r\nindex-url = https:\/\/mirrors.huaweicloud.com\/repository\/pypi\/simple\r\ntrusted-host = mirrors.huaweicloud.com\r\ntimeout = 120<\/code><\/pre>\n<p>\u6700\u540e\u76f4\u63a5\u75283.12\u7684Python\u7f16\u8bd1<\/p>\n<pre class=\"cp-code\"><code># python3.12 -m pip install torch==2.7.0\r\n# export MAX_JOBS=100\r\n# bash .\/ci\/build.sh --python=3.12\r\n# pip install --upgrade torch_npu-2.7.1.post6+git422f6d9-cp312-cp312-linux_aarch64.whl<\/code><\/pre>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image12.png\" alt=\"image12.png\" width=\"736\" height=\"263\" loading=\"lazy\"><\/figure>\n<hr>\n<h2>\u516d\u3001\u529f\u80fd\u9a8c\u8bc1<\/h2>\n<p class=\"cp-subhead\"><strong>\u5b89\u88c5\u9a8c\u8bc1<\/strong><\/p>\n<pre class=\"cp-code\"><code># python3 -c \"import torch;import torch_npu; a = torch.randn(3, 4).npu(); print(a + a);\"<\/code><\/pre>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image13.png\" alt=\"image13.png\" width=\"1208\" height=\"97\" loading=\"lazy\"><\/figure>\n<p><strong>\u8fd0\u884ctensor.clone()\uff0c\u89c2\u5bdf\u65e5\u5fd7\u8f93\u51fa<\/strong><\/p>\n<pre class=\"cp-code\"><code># cat &gt; test\/test.py &lt;&lt; 'EOF'\r\nimport torch\r\nimport torch_npu\r\nx = torch.randn(2, 2).npu()\r\ny = x.clone()\r\nprint(y)\r\nEOF\r\n# python3.12 \/workspace\/pytorch\/test\/test.py<\/code><\/pre>\n<figure class=\"cp-figure\"><img decoding=\"async\" src=\"https:\/\/nelliemylove.cn\/nelliemylove\/wp-content\/themes\/cyberpunk-blog\/assets\/images\/posts\/ascend\/image14.png\" alt=\"image14.png\" width=\"1282\" height=\"104\" loading=\"lazy\"><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u6b21\u5728\u534e\u4e3a HiDevLab\uff08CANN 9.0.0 + openEuler \u955c\u50cf\uff09\u4e0a\u4ece\u6e90\u7801\u7f16\u8bd1 torch_npu \u7684\u5b8c\u6574\u5b9e\u6218\uff1a\u6e90\u7801\u83b7\u53d6\u4e0e\u65e5\u5fd7\u6539\u9020\u3001GCC 11.2.0 \/ CMake 3.18.4 \u7f16\u8bd1\u8e29\u5751\u4fee\u590d\u3001Whl \u6253\u5305\u5b89\u88c5\u4e0e NPU \u529f\u80fd\u9a8c\u8bc1\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,65,26],"tags":[46,64],"class_list":["post-660","post","type-post","status-publish","format-standard","hentry","category-ai","category-huawei-ascend","category-tech-share","tag-ai","tag-64"],"_links":{"self":[{"href":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/wp-json\/wp\/v2\/posts\/660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/wp-json\/wp\/v2\/comments?post=660"}],"version-history":[{"count":3,"href":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/wp-json\/wp\/v2\/posts\/660\/revisions"}],"predecessor-version":[{"id":664,"href":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/wp-json\/wp\/v2\/posts\/660\/revisions\/664"}],"wp:attachment":[{"href":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/wp-json\/wp\/v2\/media?parent=660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/wp-json\/wp\/v2\/categories?post=660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nelliemylove.cn\/nelliemylove\/index.php\/wp-json\/wp\/v2\/tags?post=660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}