WebCal
Ctrl K

मार्गदर्शिका

MooreThread GPU

मार्गदर्शिकाएकीकरणसामान्य प्रश्नसहायता
मूल्यब्लॉग
त्वरित प्रारंभTop-Up and BillingAccelerating Access to Academic ResourcesQuick StartIntroductionMaintenance and TroubleshootingNetwork
प्लेटफ़ॉर्मJetBrain ProjectorTmpWebCal Scholars Program @2026Introduction to the Public Beta/Suqian Zone AAbout UsCopying Data Between InstancesAnalysis of Server Performance MetricsTidal Computing PowerLoad Balancing
घरेलू चिप्सUsing Huawei MindIEHuawei Ascend NPUMooreThread GPU
परिवेश सेटअपCUDA/cuDNNMinicondaPython3.XInstalling DependenciesOverviewImages
एंटरप्राइज़ सुविधाएँFlexible DeploymentElastic Deployment Release NotesBest Practices for Elastic DeploymentPerformance Metrics Monitoring
कंटेनर इंस्टेंसJupyterLabRemote SSH ConnectionSave the imageScaling ConfigurationMulti-machine, multi-GPU parallel processingDaemonOverviewChange the billing methodMigration Example (Same Region)Migration ExamplesRemote DesktopReset the system
GPU चुननाGPU SelectionPerformance Testing
डेटाUpload DataDownload DataPublic DataPublic Cloud Storage (Highly Recommended)Compression / DecompressionFile StorageLocal data diskOverview
सर्वोत्तम अभ्यासFileZillaGitGromacsHuggingFaceKataGoLinux BasicsMPIOpenCLPyCharm Remote DevelopmentR (RStudio) InstallationSSH TunnelTensorBoardRemote Development with VSCodeVisdomVulkanXShellOpen PortsWeChat MessagesPerformanceExpose multiple servicesMoney-Saving TipsComputation Precision IssuesSoftware Sources

घरेलू चिप्स

MooreThread GPU

30/07/202656816 व्यू

Using PyTorch

First, we recommend creating an instance using one of our pre-built base images that includes the PyTorch framework. Then, for NVIDIA-based PyTorch code, just a few simple modifications are needed to run it on MooreThread GPUs. Please see the example below:

# NVIDIA PyTorch 代码
import torch

x = torch.randn(10000, 10000).cuda()
y = torch.randn(10000, 10000).cuda()
for _ in range(1000):
    z = x.mm(y)
print(z)


# 改造为摩尔线程GPU上可运行的代码
# 第一步:import torch后,立即import torch_musa(musa为摩尔的'cuda')
# 第二步:cuda()函数换为musa()
import torch
import torch_musa

x = torch.randn(10000, 10000).musa()
y = torch.randn(10000, 10000).musa()
for _ in range(1000):
    z = x.mm(y)
print(z)

More Complex Examples

The following is the code for training a NVIDIA PyTorch ResNet network using the MNIST dataset

# 下载代码
wget https://webcal-public.ks3-cn-beijing.ksyuncs.com/debug/dp_res18.py

# 执行代码训练,自动会下载MNIST数据集
python dp_res18.py

Below is the code modified from the above to support MooreThread GPUs:

# 下载代码
wget https://webcal-public.ks3-cn-beijing.ksyuncs.com/npu_chips/moore_threads/dp_res18_mt.py

# 执行代码训练,自动会下载MNIST数据集
python dp_res18_mt.py

Differences between the two code snippets:

# diff dp_res18.py dp_res18_mt.py
8a9
> import torch_musa
29c30,31
< device = 'cuda' if torch.cuda.is_available() else 'cpu'
---
> device = 'musa' if torch.musa.is_available() else 'cpu'
> print("Detect device:", device)


# 从diff两个文件的结果可以看出,除多了import torch_musa和替换了cuda→musa,其他均相同

MooreThread GPU Utilization Monitoring

View GPU utilization, GPU memory usage, and more

Use the mthreads-gmi command

# mthreads-gmi
Fri Apr 18 15:41:55 2025
---------------------------------------------------------------
    mthreads-gmi:1.14.0          Driver Version:2.7.0
---------------------------------------------------------------
ID   Name           |PCIe                |%GPU  Mem
     Device Type    |Pcie Lane Width     |Temp  MPC Capable
                                         |      ECC Mode
+-------------------------------------------------------------+
0    MTT S4000      |00000000:12:00.0    |0%    4MiB(49152MiB)
     Physical       |16x(16x)            |41C   YES
                                         |      N/A
---------------------------------------------------------------

---------------------------------------------------------------
Processes:
ID   PID       Process name                         GPU Memory
                                                         Usage
+-------------------------------------------------------------+
   No running processes found
---------------------------------------------------------------

More algorithms and models will soon be available on the CodeWithGPU community. You can also visit MooreThread’s official GitHub model repository to access even more models!

अगला लेखBest Practices for Elastic Deployment
Compute Rental दस्तावेज़मार्गदर्शिका पर वापस जाएं