{"id":21416,"date":"2024-07-25T10:47:38","date_gmt":"2024-07-25T02:47:38","guid":{"rendered":"https:\/\/aif.amtbbs.org\/?p=21416"},"modified":"2024-07-25T10:47:38","modified_gmt":"2024-07-25T02:47:38","slug":"%e5%a6%82%e4%bd%95%e4%bc%98%e5%8c%96pytorch%e4%bb%a5%e5%8a%a0%e5%bf%ab%e6%a8%a1%e5%9e%8b%e8%ae%ad%e7%bb%83%e9%80%9f%e5%ba%a6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/aif.amtbbs.org\/index.php\/2024\/07\/25\/21416\/","title":{"rendered":"\u5982\u4f55\u4f18\u5316PyTorch\u4ee5\u52a0\u5feb\u6a21\u578b\u8bad\u7ec3\u901f\u5ea6\uff1f"},"content":{"rendered":"<p style=\"font-weight: 400;\">\u672c\u6587\u5c06\u5206\u4eab\u51e0\u4e2a\u6700\u65b0\u7684\u6027\u80fd\u8c03\u4f18\u6280\u5de7\uff0c\u4ee5\u52a0\u901f\u8de8\u9886\u57df\u7684\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7684\u8bad\u7ec3\u3002\u8fd9\u4e9b\u6280\u5de7\u5bf9\u4efb\u4f55\u60f3\u8981\u4f7f\u7528PyTorch\u5b9e\u73b0\u9ad8\u7ea7\u6027\u80fd\u8c03\u4f18\u7684\u4eba\u90fd\u5927\u6709\u5e2e\u52a9\u3002<\/p>\n<p><img data-dominant-color=\"2d4257\" data-has-transparency=\"false\" style=\"--dominant-color: #2d4257;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-21418\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/07\/32e694a6323af3d3ed34355ba645a8481458d8-300x178-1.png\" width=\"300\" height=\"178\" alt=\"\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/07\/32e694a6323af3d3ed34355ba645a8481458d8-300x178-1.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/07\/32e694a6323af3d3ed34355ba645a8481458d8-300x178-1-150x89.png 150w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>PyTorch\u662f\u5f53\u4eca\u751f\u4ea7\u73af\u5883\u4e2d\u6700\u6d41\u884c\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u4e4b\u4e00\u3002\u968f\u7740\u6a21\u578b\u53d8\u5f97\u65e5\u76ca\u590d\u6742\u3001\u6570\u636e\u96c6\u65e5\u76ca\u5e9e\u5927\uff0c\u4f18\u5316\u6a21\u578b\u8bad\u7ec3\u6027\u80fd\u5bf9\u4e8e\u7f29\u77ed\u8bad\u7ec3\u65f6\u95f4\u548c\u63d0\u9ad8\u751f\u4ea7\u529b\u53d8\u5f97\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p>\u672c\u6587\u5c06\u5206\u4eab\u51e0\u4e2a\u6700\u65b0\u7684\u6027\u80fd\u8c03\u4f18\u6280\u5de7\uff0c\u4ee5\u52a0\u901f\u8de8\u9886\u57df\u7684\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7684\u8bad\u7ec3\u3002\u8fd9\u4e9b\u6280\u5de7\u5bf9\u4efb\u4f55\u60f3\u8981\u4f7f\u7528PyTorch\u5b9e\u73b0\u9ad8\u7ea7\u6027\u80fd\u8c03\u4f18\u7684\u4eba\u90fd\u5927\u6709\u5e2e\u52a9\u3002<\/p>\n<h3>\u6280\u5de71\uff1a\u901a\u8fc7\u5206\u6790\u8bc6\u522b\u6027\u80fd\u74f6\u9888<\/h3>\n<p>\u5728\u5f00\u59cb\u8c03\u4f18\u4e4b\u524d\uff0c\u4f60\u5e94\u8be5\u4e86\u89e3\u6a21\u578b\u8bad\u7ec3\u7ba1\u9053\u4e2d\u7684\u74f6\u9888\u3002\u5206\u6790(Profiling)\u662f\u4f18\u5316\u8fc7\u7a0b\u4e2d\u7684\u5173\u952e\u6b65\u9aa4\uff0c\u56e0\u4e3a\u5b83\u6709\u52a9\u4e8e\u8bc6\u522b\u9700\u8981\u6ce8\u610f\u7684\u5185\u5bb9\u3002\u4f60\u53ef\u4ee5\u4ecePyTorch\u7684\u5185\u7f6e\u81ea\u52a8\u6c42\u68af\u5ea6\u5206\u6790\u5668\u3001TensorBoard\u548c\u82f1\u4f1f\u8fbe\u7684Nsight\u7cfb\u7edf\u4e2d\u8fdb\u884c\u9009\u62e9\u3002\u4e0b\u9762\u4e0d\u59a8\u770b\u4e00\u4e0b\u4e09\u4e2a\u793a\u4f8b\u3002<\/p>\n<ul data-id=\"u738a58b-VLYcghVM\">\n<li data-id=\"ld70c578-LFhDNfYc\">\u4ee3\u7801\u793a\u4f8b\uff1a\u81ea\u52a8\u6c42\u68af\u5ea6\u5206\u6790\u5668<\/li>\n<\/ul>\n<p>\u590d\u5236<\/p>\n<p>import torch.autograd.profiler as profiler with profiler.profile(use_cuda=True) as prof: # Run your model training code here print(prof.key_averages().table(sort_by=&#8221;cuda_time_total&#8221;, row_limit=10))<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<\/ul>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0cPyTorch\u7684\u5185\u7f6e\u81ea\u52a8\u6c42\u68af\u5ea6\u5206\u6790\u5668\u8bc6\u522b\u68af\u5ea6\u8ba1\u7b97\u5f00\u9500\u3002use_cuda=True\u53c2\u6570\u6307\u5b9a\u4f60\u60f3\u8981\u5206\u6790CUDA\u5185\u6838\u6267\u884c\u65f6\u95f4\u3002prof.key_average()\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u6c47\u603b\u5206\u6790\u7ed3\u679c\u7684\u8868\uff0c\u6309\u603b\u7684CUDA\u65f6\u95f4\u6392\u5e8f\u3002<\/p>\n<ul data-id=\"u738a58b-F8GScKid\">\n<li data-id=\"ld70c578-O39lWIBU\">\u4ee3\u7801\u793a\u4f8b\uff1aTensorBoard\u96c6\u6210<\/li>\n<\/ul>\n<p>\u590d\u5236<\/p>\n<p>import torch.utils.tensorboard as tensorboard writer = tensorboard.SummaryWriter() # Run your model training code here writer.add_scalar(&#8216;loss&#8217;, loss.item(), global_step) writer.close()<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<\/ul>\n<p>\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528TensorBoard\u96c6\u6210\u6765\u663e\u793a\u548c\u5206\u6790\u6a21\u578b\u8bad\u7ec3\u3002SummaryWriter\u7c7b\u5c06\u6c47\u603b\u6570\u636e\u5199\u5165\u5230\u4e00\u4e2a\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u53ef\u4ee5\u4f7f\u7528TensorBoard GUI\u52a0\u4ee5\u663e\u793a\u3002<\/p>\n<ul data-id=\"u738a58b-Bi0MGFoD\">\n<li data-id=\"ld70c578-0kgDZLO3\">\u4ee3\u7801\u793a\u4f8b\uff1a\u82f1\u4f1f\u8fbeNsight Systems<\/li>\n<\/ul>\n<p>\u590d\u5236<\/p>\n<p>nsys profile -t cpu,gpu,memory python your_script.py<\/p>\n<ul>\n<li>1.<\/li>\n<\/ul>\n<p>\u5bf9\u4e8e\u7cfb\u7edf\u7ea7\u5206\u6790\uff0c\u53ef\u4ee5\u8003\u8651\u82f1\u4f1f\u8fbe\u7684Nsight Systems\u6027\u80fd\u5206\u6790\u5de5\u5177\u3002\u4e0a\u9762\u7684\u547d\u4ee4\u5206\u6790\u4e86Python\u811a\u672c\u7684CPU\u3001GPU\u548c\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<h3>\u6280\u5de72\uff1a\u52a0\u901f\u6570\u636e\u52a0\u8f7d\u4ee5\u63d0\u5347\u901f\u5ea6\u548cGPU\u5229\u7528\u7387<\/h3>\n<p>\u6570\u636e\u52a0\u8f7d\u662f\u6a21\u578b\u8bad\u7ec3\u7ba1\u9053\u7684\u5173\u952e\u7ec4\u6210\u90e8\u5206\u3002\u5728\u5178\u578b\u7684\u673a\u5668\u5b66\u4e60\u8bad\u7ec3\u7ba1\u9053\u4e2d\uff0cPyTorch\u7684\u6570\u636e\u52a0\u8f7d\u5668\u5728\u6bcf\u4e2a\u8bad\u7ec3\u8f6e\u6b21\u5f00\u59cb\u65f6\u4ece\u5b58\u50a8\u4e2d\u52a0\u8f7d\u6570\u636e\u96c6\u3002\u7136\u540e\uff0c\u6570\u636e\u96c6\u88ab\u4f20\u8f93\u5230GPU\u5b9e\u4f8b\u7684\u672c\u5730\u5b58\u50a8\uff0c\u5e76\u5728GPU\u5185\u5b58\u4e2d\u8fdb\u884c\u5904\u7406\u3002\u5982\u679c\u6570\u636e\u4f20\u8f93\u5230GPU\u7684\u901f\u5ea6\u8ddf\u4e0d\u4e0aGPU\u7684\u8ba1\u7b97\u901f\u5ea6\uff0c\u5c31\u4f1a\u5bfc\u81f4GPU\u5468\u671f\u6d6a\u8d39\u3002\u56e0\u6b64\uff0c\u4f18\u5316\u6570\u636e\u52a0\u8f7d\u5bf9\u4e8e\u52a0\u5feb\u8bad\u7ec3\u901f\u5ea6\u3001\u5c3d\u91cf\u63d0\u5347GPU\u5229\u7528\u7387\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p>\u4e3a\u4e86\u5c3d\u91cf\u51cf\u5c11\u6570\u636e\u52a0\u8f7d\u74f6\u9888\uff0c\u4f60\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u4f18\u5316\uff1a<\/p>\n<ol data-id=\"o9d5df12-jTieLR5Q\">\n<li data-id=\"ld70c578-26L8ZcUi\">\u4f7f\u7528\u591a\u4e2aworker\u5e76\u884c\u5316\u6570\u636e\u52a0\u8f7d\uff1a\u4f7f\u7528PyTorch\u7684\u6570\u636e\u52a0\u8f7d\u5668\u4e0e\u591a\u4e2aworker\u5e76\u884c\u5316\u6570\u636e\u52a0\u8f7d\u3002\u8fd9\u5141\u8bb8CPU\u5e76\u884c\u52a0\u8f7d\u548c\u5904\u7406\u6570\u636e\uff0c\u4ece\u800c\u51cf\u5c11GPU\u7a7a\u95f2\u65f6\u95f4\u3002<\/li>\n<li data-id=\"ld70c578-jJ8np7cA\">\u4f7f\u7528\u7f13\u5b58\u52a0\u901f\u6570\u636e\u52a0\u8f7d\uff1a\u4f7f\u7528Alluxio\u4f5c\u4e3a\u8bad\u7ec3\u8282\u70b9\u548c\u5b58\u50a8\u4e4b\u95f4\u7684\u7f13\u5b58\u5c42\uff0c\u4ee5\u5b9e\u73b0\u6570\u636e\u6309\u9700\u52a0\u8f7d\uff0c\u800c\u4e0d\u662f\u5c06\u8fdc\u7a0b\u6570\u636e\u76f4\u63a5\u52a0\u8f7d\u5230\u672c\u5730\u5b58\u50a8\u6216\u5c06\u8bad\u7ec3\u6570\u636e\u590d\u5236\u5230\u672c\u5730\u5b58\u50a8\u3002<\/li>\n<\/ol>\n<ul data-id=\"u738a58b-FZTJi196\">\n<li data-id=\"ld70c578-Zqr03FJV\">\u4ee3\u7801\u793a\u4f8b\uff1a\u5e76\u884c\u5316\u6570\u636e\u52a0\u8f7d<\/li>\n<\/ul>\n<p>\u4e0b\u9762\u8fd9\u4e2a\u793a\u4f8b\u662f\u4f7f\u7528PyTorch\u7684\u6570\u636e\u52a0\u8f7d\u5668\u548c\u591a\u4e2aworker\u5e76\u884c\u5316\u52a0\u8f7d\u6570\u636e\uff1a<\/p>\n<p>\u590d\u5236<\/p>\n<p>import torch from torch.utils.data import DataLoader, Dataset class MyDataset(Dataset): def __init__(self, data_path): self.data_path = data_path def __getitem__(self, index): # Load and process data for the given index data = load_data(self.data_path, index) data = preprocess_data(data) return data def __len__(self): return len(self.data_path) dataset = MyDataset(data_path=&#8217;path\/to\/data&#8217;) data_loader = DataLoader(dataset, batch_size=32, num_workers=4) for batch in data_loader: # Process the batch on the GPU inputs, labels = batch outputs = model(inputs) loss = criterion(outputs, labels) optimizer.zero_grad() loss.backward() optimizer.step()<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<\/ul>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u5b9a\u4e49\u4e86\u81ea\u5b9a\u4e49\u6570\u636e\u96c6\u7c7bMyDataset\u3002\u5b83\u4e3a\u6bcf\u4e2a\u7d22\u5f15\u52a0\u8f7d\u548c\u5904\u7406\u6570\u636e\u3002\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u6709\u591a\u4e2aworker(\u672c\u4f8b\u4e2d\u6709\u56db\u4e2a)\u7684\u6570\u636e\u52a0\u8f7d\u5668\u5b9e\u4f8b\u6765\u5e76\u884c\u5316\u52a0\u8f7d\u6570\u636e\u3002<\/p>\n<ul data-id=\"u738a58b-SASQ0a7e\">\n<li data-id=\"ld70c578-hUR03KPh\">\u4ee3\u7801\u793a\u4f8b\uff1a\u4f7f\u7528Alluxio\u7f13\u5b58\u6765\u52a0\u901fPyTorch\u7684\u6570\u636e\u52a0\u8f7d<\/li>\n<\/ul>\n<p>Alluxio\u662f\u4e00\u4e2a\u5f00\u6e90\u5206\u5e03\u5f0f\u7f13\u5b58\u7cfb\u7edf\uff0c\u63d0\u4f9b\u5feb\u901f\u8bbf\u95ee\u6570\u636e\u7684\u673a\u5236\u3002Alluxio\u7f13\u5b58\u53ef\u4ee5\u8bc6\u522b\u4ece\u5e95\u90e8\u5b58\u50a8(\u6bd4\u5982Amazon S3)\u9891\u7e41\u8bbf\u95ee\u7684\u6570\u636e\uff0c\u5e76\u5728Alluxio\u96c6\u7fa4\u7684NVMe\u5b58\u50a8\u4e0a\u5206\u5e03\u5f0f\u5b58\u50a8\u70ed\u6570\u636e\u7684\u591a\u4e2a\u526f\u672c\u3002\u5982\u679c\u4f7f\u7528Alluxio\u4f5c\u4e3a\u7f13\u5b58\u5c42\uff0c\u4f60\u53ef\u4ee5\u663e\u8457\u7f29\u77ed\u5c06\u6570\u636e\u52a0\u8f7d\u5230\u8bad\u7ec3\u8282\u70b9\u6240\u9700\u7684\u65f6\u95f4\uff0c\u8fd9\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u96c6\u6216\u6162\u901f\u5b58\u50a8\u7cfb\u7edf\u65f6\u7279\u522b\u6709\u7528\u3002<\/p>\n<p>\u4e0b\u9762\u8fd9\u4e2a\u793a\u4f8b\u8868\u660e\u4e86\u4f60\u5982\u4f55\u4f7f\u7528Alluxio\u4e0ePyTorch\u548cfsspec(\u6587\u4ef6\u7cfb\u7edf\u89c4\u8303)\u6765\u52a0\u901f\u6570\u636e\u52a0\u8f7d\uff1a<\/p>\n<p>\u9996\u5148\uff0c\u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56\u9879\uff1a<\/p>\n<p>\u590d\u5236<\/p>\n<p>pip install alluxiofs pip install s3fs<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<\/ul>\n<p>\u63a5\u4e0b\u6765\uff0c\u521b\u5efa\u4e00\u4e2aAlluxio\u5b9e\u4f8b\uff1a<\/p>\n<p>\u590d\u5236<\/p>\n<p>import fsspec from alluxiofs import AlluxioFileSystem # Register Alluxio to fsspec fsspec.register_implementation(&#8220;alluxiofs&#8221;, AlluxioFileSystem, clobber=True) # Create Alluxio instance alluxio_fs = fsspec.filesystem(&#8220;alluxiofs&#8221;, etcd_hosts=&#8221;localhost&#8221;, target_protocol=&#8221;s3&#8243;)<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<\/ul>\n<p>\u7136\u540e\uff0c\u4f7f\u7528Alluxio\u548cPyArrow\u5728PyTorch\u4e2d\u52a0\u8f7dParquet\u6587\u4ef6\u8fd9\u4e2a\u6570\u636e\u96c6\uff1a<\/p>\n<p>\u590d\u5236<\/p>\n<p># Example: Read a Parquet file using Pyarrow import pyarrow.dataset as ds dataset = ds.dataset(&#8220;s3:\/\/example_bucket\/datasets\/example.parquet&#8221;, filesystem=alluxio_fs) # Get a count of the number of records in the parquet file dataset.count_rows() # Display the schema derived from the parquet file header record dataset.schema # Display the first record dataset.take(0)<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<\/ul>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u521b\u5efa\u4e86\u4e00\u4e2aAlluxio\u5b9e\u4f8b\u5e76\u5c06\u5176\u4f20\u9012\u7ed9PyArrow\u7684dataset\u51fd\u6570\u3002\u8fd9\u5141\u8bb8\u6211\u4eec\u901a\u8fc7Alluxio\u7f13\u5b58\u5c42\u4ece\u5e95\u5c42\u5b58\u50a8\u7cfb\u7edf(\u672c\u4f8b\u4e2d\u4e3aS3)\u8bfb\u53d6\u6570\u636e\u3002<\/p>\n<h3>\u6280\u5de73\uff1a\u4e3a\u8d44\u6e90\u5229\u7528\u7387\u4f18\u5316\u6279\u4efb\u52a1\u5927\u5c0f<\/h3>\n<p>\u4f18\u5316GPU\u5229\u7528\u7387\u7684\u53e6\u4e00\u9879\u91cd\u8981\u6280\u672f\u662f\u8c03\u6574\u6279\u4efb\u52a1\u5927\u5c0f\uff0c\u5b83\u4f1a\u663e\u8457\u5f71\u54cdGPU\u548c\u5185\u5b58\u5229\u7528\u7387\u3002<\/p>\n<ul data-id=\"u738a58b-8Ppk8AL7\">\n<li data-id=\"ld70c578-GjeaJBZF\">\u4ee3\u7801\u793a\u4f8b\uff1a\u6279\u4efb\u52a1\u5927\u5c0f\u4f18\u5316<\/li>\n<\/ul>\n<p>\u590d\u5236<\/p>\n<p>import torch import torchvision import torchvision.transforms as transforms # Define the model and optimizer model = torchvision.models.resnet50(pretrained=True) optimizer = torch.optim.SGD(model.parameters(), lr=0.01) # Define the data loader with a batch size of 32 data_loader = torch.utils.data.DataLoader( dataset, batch_size=32, shuffle=True, num_workers=4 ) # Train the model with the optimized batch size for epoch in range(5): for inputs, labels in data_loader: inputs, labels = inputs.cuda(), labels.cuda() optimizer.zero_grad() outputs = model(inputs) loss = torch.nn.CrossEntropyLoss()(outputs, labels) loss.backward() optimizer.step()<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<\/ul>\n<p>\u5728\u672c\u4f8b\u4e2d\uff0c\u6279\u4efb\u52a1\u5927\u5c0f\u5b9a\u4e49\u4e3a32\u3002batch_size\u53c2\u6570\u6307\u5b9a\u4e86\u6bcf\u4e2a\u6279\u4e2d\u7684\u6837\u672c\u6570\u91cf\u3002shuffle=True\u53c2\u6570\u968f\u673a\u5316\u6279\u5904\u7406\u7684\u987a\u5e8f\uff0cnum_workers=4\u53c2\u6570\u6307\u5b9a\u7528\u4e8e\u52a0\u8f7d\u6570\u636e\u7684worker\u7ebf\u7a0b\u7684\u6570\u91cf\u3002\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4e0d\u540c\u7684\u6279\u4efb\u52a1\u5927\u5c0f\uff0c\u4ee5\u627e\u5230\u5728\u53ef\u7528\u5185\u5b58\u8303\u56f4\u5185\u5c3d\u91cf\u63d0\u9ad8GPU\u5229\u7528\u7387\u7684\u6700\u4f73\u503c\u3002<\/p>\n<h3>\u6280\u5de74\uff1a\u53ef\u8bc6\u522bGPU\u7684\u6a21\u578b\u5e76\u884c\u6027<\/h3>\n<p>\u5904\u7406\u5927\u578b\u590d\u6742\u6a21\u578b\u65f6\uff0c\u5355\u4e2aGPU\u7684\u9650\u5236\u53ef\u80fd\u4f1a\u6210\u4e3a\u8bad\u7ec3\u7684\u74f6\u9888\u3002\u6a21\u578b\u5e76\u884c\u5316\u53ef\u4ee5\u901a\u8fc7\u5728\u591a\u4e2aGPU\u4e0a\u5171\u540c\u5206\u5e03\u6a21\u578b\u4ee5\u4f7f\u7528\u5b83\u4eec\u7684\u52a0\u901f\u80fd\u529b\u6765\u514b\u670d\u8fd9\u4e00\u6311\u6218\u3002<\/p>\n<h4>1.\u5229\u7528PyTorch\u7684DistributedDataParallel(DDP)\u6a21\u5757<\/h4>\n<p>PyTorch\u63d0\u4f9b\u4e86DistributedDataParallel(DDP)\u6a21\u5757\uff0c\u5b83\u53ef\u4ee5\u901a\u8fc7\u652f\u6301\u591a\u4e2a\u540e\u7aef\u6765\u5b9e\u73b0\u7b80\u5355\u7684\u6a21\u578b\u5e76\u884c\u5316\u3002\u4e3a\u4e86\u5c3d\u91cf\u63d0\u9ad8\u6027\u80fd\uff0c\u4f7f\u7528NCCL\u540e\u7aef\uff0c\u5b83\u9488\u5bf9\u82f1\u4f1f\u8fbeGPU\u8fdb\u884c\u4e86\u4f18\u5316\u3002\u5982\u679c\u4f7f\u7528DDP\u6765\u5c01\u88c5\u6a21\u578b\uff0c\u4f60\u53ef\u4ee5\u8de8\u591a\u4e2aGPU\u65e0\u7f1d\u5206\u5e03\u6a21\u578b\uff0c\u5c06\u8bad\u7ec3\u6269\u5c55\u5230\u524d\u6240\u672a\u6709\u7684\u5c42\u9762\u3002<\/p>\n<ul data-id=\"u738a58b-HHXiZDCY\">\n<li data-id=\"ld70c578-r1GEAniE\">\u4ee3\u7801\u793a\u4f8b\uff1a\u4f7f\u7528DDP<\/li>\n<\/ul>\n<p>\u590d\u5236<\/p>\n<p>import torch from torch.nn.parallel import DistributedDataParallel as DDP # Define your model and move it to the desired device(s) model = MyModel() device_ids = [0, 1, 2, 3] # Use 4 GPUs for training model.to(device_ids[0]) model_ddp = DDP(model, device_ids=device_ids) # Train your model as usual<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<\/ul>\n<h4>2.\u4f7f\u7528PyTorch\u7684Pipe\u6a21\u5757\u5b9e\u73b0\u7ba1\u9053\u5e76\u884c\u5904\u7406<\/h4>\n<p>\u5bf9\u4e8e\u9700\u8981\u987a\u5e8f\u5904\u7406\u7684\u6a21\u578b\uff0c\u6bd4\u5982\u90a3\u4e9b\u5177\u6709\u5faa\u73af\u6216\u81ea\u56de\u5f52\u7ec4\u4ef6\u7684\u6a21\u578b\uff0c\u7ba1\u9053\u5e76\u884c\u6027\u53ef\u4ee5\u6539\u53d8\u6e38\u620f\u89c4\u5219\u3002PyTorch\u7684Pipe\u5141\u8bb8\u4f60\u5c06\u6a21\u578b\u5206\u89e3\u4e3a\u66f4\u5c0f\u7684\u90e8\u5206\uff0c\u5728\u5355\u72ec\u7684GPU\u4e0a\u5904\u7406\u6bcf\u4e2a\u90e8\u5206\u3002\u8fd9\u4f7f\u5f97\u590d\u6742\u6a21\u578b\u53ef\u4ee5\u9ad8\u6548\u5e76\u884c\u5316\uff0c\u7f29\u77ed\u4e86\u8bad\u7ec3\u65f6\u95f4\uff0c\u63d0\u9ad8\u4e86\u6574\u4f53\u7cfb\u7edf\u5229\u7528\u7387\u3002<\/p>\n<h4>3.\u51cf\u5c11\u901a\u4fe1\u5f00\u9500<\/h4>\n<p>\u867d\u7136\u6a21\u578b\u5e76\u884c\u5316\u63d0\u4f9b\u4e86\u5de8\u5927\u7684\u597d\u5904\uff0c\u4f46\u4e5f\u5e26\u6765\u4e86\u8bbe\u5907\u4e4b\u95f4\u7684\u901a\u4fe1\u5f00\u9500\u3002\u4ee5\u4e0b\u662f\u5c3d\u91cf\u51cf\u5c0f\u5f71\u54cd\u7684\u51e0\u4e2a\u5efa\u8bae\uff1a<\/p>\n<p>a.\u6700\u5c0f\u5316\u68af\u5ea6\u805a\u5408\uff1a\u901a\u8fc7\u4f7f\u7528\u66f4\u5927\u7684\u6279\u5927\u5c0f\u6216\u5728\u540c\u6b65\u4e4b\u524d\u672c\u5730\u7d2f\u79ef\u68af\u5ea6\uff0c\u51cf\u5c11\u68af\u5ea6\u805a\u5408\u7684\u9891\u6b21\u3002<\/p>\n<p>b.\u4f7f\u7528\u5f02\u6b65\u66f4\u65b0\uff1a\u4f7f\u7528\u5f02\u6b65\u66f4\u65b0\uff0c\u9690\u85cf\u5ef6\u8fdf\u548c\u6700\u5927\u5316GPU\u5229\u7528\u7387\u3002<\/p>\n<p>c.\u542f\u7528NCCL\u7684\u5206\u5c42\u901a\u4fe1\uff1a\u8ba9NCCL\u5e93\u51b3\u5b9a\u4f7f\u7528\u54ea\u79cd\u5206\u5c42\u7b97\u6cd5\uff1a\u73af\u8fd8\u662f\u6811\uff0c\u8fd9\u53ef\u4ee5\u51cf\u5c11\u7279\u5b9a\u573a\u666f\u4e0b\u7684\u901a\u4fe1\u5f00\u9500\u3002<\/p>\n<p>d.\u8c03\u6574NCCL\u7684\u7f13\u51b2\u533a\u5927\u5c0f\uff1a\u8c03\u6574NCCL_BUFF_SIZE\u73af\u5883\u53d8\u91cf\uff0c\u4e3a\u4f60\u7684\u7279\u5b9a\u7528\u4f8b\u4f18\u5316\u7f13\u51b2\u533a\u5927\u5c0f\u3002<\/p>\n<h3>\u6280\u5de75\uff1a\u6df7\u5408\u7cbe\u5ea6\u8bad\u7ec3<\/h3>\n<p>\u6df7\u5408\u7cbe\u5ea6\u8bad\u7ec3\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u6280\u672f\uff0c\u53ef\u4ee5\u663e\u8457\u52a0\u901f\u6a21\u578b\u8bad\u7ec3\u3002\u901a\u8fc7\u5229\u7528\u73b0\u4ee3\u82f1\u4f1f\u8fbeGPU\u7684\u529f\u80fd\uff0c\u4f60\u53ef\u4ee5\u51cf\u5c11\u8bad\u7ec3\u6240\u9700\u7684\u8ba1\u7b97\u8d44\u6e90\uff0c\u4ece\u800c\u52a0\u5feb\u8fed\u4ee3\u65f6\u95f4\u5e76\u63d0\u9ad8\u751f\u4ea7\u529b\u3002<\/p>\n<h4>1.\u4f7f\u7528Tensor Cores\u52a0\u901f\u8bad\u7ec3<\/h4>\n<p>\u82f1\u4f1f\u8fbe\u7684Tensor Cores\u662f\u4e13\u95e8\u7528\u4e8e\u52a0\u901f\u77e9\u9635\u4e58\u6cd5\u7684\u786c\u4ef6\u5757\u3002\u8fd9\u4e9b\u6838\u5fc3\u53ef\u4ee5\u6bd4\u4f20\u7edf\u7684CUDA\u6838\u5fc3\u66f4\u5feb\u5730\u6267\u884c\u67d0\u4e9b\u64cd\u4f5c\u3002<\/p>\n<h4>2.\u4f7f\u7528PyTorch\u7684AMP\u7b80\u5316\u6df7\u5408\u7cbe\u5ea6\u8bad\u7ec3<\/h4>\n<p>\u5b9e\u73b0\u6df7\u5408\u7cbe\u5ea6\u8bad\u7ec3\u53ef\u80fd\u5f88\u590d\u6742\uff0c\u800c\u4e14\u5bb9\u6613\u51fa\u9519\u3002\u5e78\u597d\uff0cPyTorch\u63d0\u4f9b\u4e86\u4e00\u4e2aamp\u6a21\u5757\u6765\u7b80\u5316\u8fd9\u4e2a\u8fc7\u7a0b\u3002\u4f7f\u7528\u81ea\u52a8\u6df7\u5408\u7cbe\u5ea6(AMP)\uff0c\u4f60\u53ef\u4ee5\u9488\u5bf9\u6a21\u578b\u7684\u4e0d\u540c\u90e8\u5206\u5728\u4e0d\u540c\u7cbe\u5ea6\u683c\u5f0f(\u4f8b\u5982float32\u548cfloat16)\u4e4b\u95f4\u5207\u6362\uff0c\u4ece\u800c\u4f18\u5316\u6027\u80fd\u548c\u5185\u5b58\u4f7f\u7528\u3002<\/p>\n<ul data-id=\"u738a58b-KkNEAOJB\">\n<li data-id=\"ld70c578-7DUUdo3s\">\u4ee3\u7801\u793a\u4f8b\uff1aPyTorch\u7684AMP<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u8fd9\u4e2a\u793a\u4f8b\u8868\u660e\u4e86\u5982\u4f55\u4f7f\u7528PyTorch\u7684amp\u6a21\u5757\u6765\u5b9e\u73b0\u6df7\u5408\u7cbe\u5ea6\u8bad\u7ec3\uff1a<\/p>\n<p>\u590d\u5236<\/p>\n<p>import torch from torch.amp import autocast # Define your model and optimizer model = MyModel() optimizer = torch.optim.SGD(model.parameters(), lr=0.01) # Enable mixed precision training with AMP with autocast(enabled=True, dtype=torch.float16): # Train your model as usual for epoch in range(10): optimizer.zero_grad() outputs = model(inputs) loss = criterion(outputs, labels) loss.backward() optimizer.step()<\/p>\n<ul>\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<\/ul>\n<h4>3.\u4f7f\u7528\u4f4e\u7cbe\u5ea6\u683c\u5f0f\u4f18\u5316\u5185\u5b58\u4f7f\u7528<\/h4>\n<p>\u4ee5\u8f83\u4f4e\u7cbe\u5ea6\u683c\u5f0f(\u6bd4\u5982float16)\u5b58\u50a8\u6a21\u578b\u6743\u91cd\u53ef\u4ee5\u663e\u8457\u51cf\u5c11\u5185\u5b58\u4f7f\u7528\u3002\u5f53\u5904\u7406\u5927\u578b\u6a21\u578b\u6216\u6709\u9650\u7684GPU\u8d44\u6e90\u65f6\uff0c\u8fd9\u70b9\u5c24\u4e3a\u91cd\u8981\u3002\u5982\u679c\u4f7f\u7528\u7cbe\u5ea6\u8f83\u4f4e\u7684\u683c\u5f0f\uff0c\u4f60\u53ef\u4ee5\u5c06\u8f83\u5927\u7684\u6a21\u578b\u653e\u5165\u5230\u5185\u5b58\u4e2d\uff0c\u4ece\u800c\u51cf\u5c11\u5bf9\u6602\u8d35\u5185\u5b58\u8bbf\u95ee\u7684\u9700\u6c42\uff0c\u5e76\u63d0\u9ad8\u6574\u4f53\u8bad\u7ec3\u6027\u80fd\u3002<\/p>\n<p>\u8bb0\u4f4f\u8981\u5c1d\u8bd5\u4e0d\u540c\u7684\u7cbe\u5ea6\u683c\u5f0f\u5e76\u4f18\u5316\u5185\u5b58\u4f7f\u7528\uff0c\u4ee5\u4fbf\u4e3a\u4f60\u7684\u7279\u5b9a\u7528\u4f8b\u83b7\u5f97\u6700\u4f73\u7ed3\u679c\u3002<\/p>\n<h3>\u6280\u5de76\uff1a\u65b0\u7684\u786c\u4ef6\u4f18\u5316\uff1aGPU\u548c\u7f51\u7edc<\/h3>\n<p>\u65b0\u7684\u786c\u4ef6\u6280\u672f\u51fa\u73b0\u4e3a\u52a0\u901f\u6a21\u578b\u8bad\u7ec3\u63d0\u4f9b\u4e86\u5927\u597d\u673a\u4f1a\u3002\u8bb0\u5f97\u5c1d\u8bd5\u4e0d\u540c\u7684\u786c\u4ef6\u914d\u7f6e\uff0c\u5e76\u4f18\u5316\u4f60\u7684\u5de5\u4f5c\u6d41\uff0c\u4ee5\u4fbf\u4e3a\u7279\u5b9a\u7528\u4f8b\u83b7\u5f97\u6700\u4f73\u7ed3\u679c\u3002<\/p>\n<h4>1.\u5229\u7528\u82f1\u4f1f\u8fbeA100\u548cH100 GPU<\/h4>\n<p>\u6700\u65b0\u7684\u82f1\u4f1f\u8fbeA100\u548cH100 GPU\u6709\u5148\u8fdb\u7684\u6027\u80fd\u548c\u5185\u5b58\u5e26\u5bbd\u3002\u8fd9\u4e9bGPU\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u5904\u7406\u80fd\u529b\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u8bad\u7ec3\u66f4\u5927\u7684\u6a21\u578b\u3001\u5904\u7406\u66f4\u5927\u7684\u6279\u4efb\u52a1\uff0c\u5e76\u7f29\u77ed\u8fed\u4ee3\u65f6\u95f4\u3002<\/p>\n<h4>2.\u5229\u7528NVLink\u548cInfiniBand\u52a0\u901fGPU-GPU\u901a\u4fe1<\/h4>\n<p>\u5f53\u8de8\u591a\u4e2aGPU\u8bad\u7ec3\u5927\u578b\u6a21\u578b\u65f6\uff0c\u8bbe\u5907\u4e4b\u95f4\u7684\u901a\u4fe1\u5f00\u9500\u53ef\u80fd\u6210\u4e3a\u4e00\u5927\u74f6\u9888\u3002\u82f1\u4f1f\u8fbe\u7684NVLink\u4e92\u8fde\u6280\u672f\u5728GPU\u4e4b\u95f4\u63d0\u4f9b\u4e86\u9ad8\u5e26\u5bbd\u4f4e\u5ef6\u8fdf\u7684\u94fe\u8def\uff0c\u4ece\u800c\u5b9e\u73b0\u66f4\u5feb\u7684\u6570\u636e\u4f20\u8f93\u548c\u540c\u6b65\u3002\u6b64\u5916\uff0cInfiniBand\u4e92\u8fde\u6280\u672f\u4e3a\u8fde\u63a5\u591a\u4e2aGPU\u548c\u8282\u70b9\u63d0\u4f9b\u4e86\u4e00\u79cd\u6613\u4e8e\u6269\u5c55\u7684\u9ad8\u6027\u80fd\u89e3\u51b3\u65b9\u6848\u3002\u5b83\u6709\u52a9\u4e8e\u5c3d\u91cf\u51cf\u5c0f\u901a\u4fe1\u5f00\u9500\uff0c\u7f29\u77ed\u540c\u6b65\u68af\u5ea6\u548c\u52a0\u901f\u6a21\u578b\u8bad\u7ec3\u6240\u82b1\u8d39\u7684\u65f6\u95f4\u3002<\/p>\n<h3>\u7ed3\u8bed<\/h3>\n<p>\u4e0a\u8ff0\u8fd9\u516d\u4e2a\u6280\u5de7\u5c06\u5e2e\u52a9\u4f60\u663e\u8457\u52a0\u5feb\u6a21\u578b\u8bad\u7ec3\u901f\u5ea6\u3002\u5207\u8bb0\uff0c\u83b7\u5f97\u6700\u4f73\u7ed3\u679c\u7684\u5173\u952e\u662f\u5c1d\u8bd5\u8fd9\u4e9b\u6280\u672f\u7684\u4e0d\u540c\u7ec4\u5408\uff0c\u4e3a\u4f60\u7684\u7279\u5b9a\u7528\u4f8b\u627e\u5230\u6700\u4f73\u914d\u7f6e\u3002<\/p>\n<p>\u539f\u6587\u6807\u9898\uff1aThis Is How To Optimize PyTorch for Faster Model Training\uff0c\u4f5c\u8005\uff1aHope Wang<\/p>\n<p>\u94fe\u63a5\uff1ahttps:\/\/thenewstack.io\/this-is-how-to-optimize-pytorch-for-faster-model-training\/\u3002<\/p>\n<p>\u60f3\u4e86\u89e3\u66f4\u591aAIGC\u7684\u5185\u5bb9\uff0c\u8bf7\u8bbf\u95ee\uff1a<\/p>\n<p>51CTO AI.x\u793e\u533a<\/p>\n<p>https:\/\/www.51cto.com\/aigc\/<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_21416\" class=\"pvc_stats total_only  \" data-element-id=\"21416\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.0\" viewBox=\"0 0 502 315\" preserveAspectRatio=\"xMidYMid meet\"><g transform=\"translate(0,332) scale(0.1,-0.1)\" fill=\"\" stroke=\"none\"><path d=\"M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z\"\/><path d=\"M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z\"\/><path d=\"M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z\"\/><path d=\"M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z\"\/><path d=\"M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z\"\/><path d=\"M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z\"\/><path d=\"M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z\"\/><path d=\"M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z\"\/><path d=\"M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z\"\/><\/g><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/aif.amtbbs.org\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c06\u5206\u4eab\u51e0\u4e2a\u6700\u65b0\u7684\u6027\u80fd\u8c03\u4f18\u6280\u5de7\uff0c\u4ee5\u52a0\u901f\u8de8\u9886\u57df\u7684\u673a\u5668\u5b66\u4e60\u6a21\u578b\u7684\u8bad\u7ec3\u3002\u8fd9\u4e9b\u6280\u5de7\u5bf9\u4efb\u4f55\u60f3\u8981\u4f7f\u7528PyTorch\u5b9e\u73b0\u9ad8 [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_21416\" class=\"pvc_stats total_only  \" data-element-id=\"21416\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.0\" viewBox=\"0 0 502 315\" preserveAspectRatio=\"xMidYMid meet\"><g transform=\"translate(0,332) scale(0.1,-0.1)\" fill=\"\" stroke=\"none\"><path d=\"M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z\"\/><path d=\"M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z\"\/><path d=\"M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z\"\/><path d=\"M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z\"\/><path d=\"M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z\"\/><path d=\"M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z\"\/><path d=\"M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z\"\/><path d=\"M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z\"\/><path d=\"M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z\"\/><\/g><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/aif.amtbbs.org\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":56,"featured_media":21418,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,20,80],"tags":[1232],"class_list":["post-21416","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-23","category-20","category-80","tag---pytorch"],"_links":{"self":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/21416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/users\/56"}],"replies":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/comments?post=21416"}],"version-history":[{"count":1,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/21416\/revisions"}],"predecessor-version":[{"id":21419,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/21416\/revisions\/21419"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/media\/21418"}],"wp:attachment":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/media?parent=21416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/categories?post=21416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/tags?post=21416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}