From 08745429a634f27db89a89115fe471d94bc0f9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=A4=E5=AE=89=E5=8D=87?= Date: Thu, 24 Feb 2022 15:47:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99=E5=92=8C?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.zh.md | 33 ++++++++++++++++++++++----------- test/test_npu.py | 6 +++--- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/README.zh.md b/README.zh.md index e9fcb196e59..2a04585461c 100644 --- a/README.zh.md +++ b/README.zh.md @@ -34,30 +34,41 @@ apt-get install -y gcc g++ make build-essential libssl-dev zlib1g-dev libbz2-dev # 安装方式 -## 编译安装PyTorch - -当前支持pytorch 1.5.0和1.8.1的版本。根据需求,在当前仓库根目录pytorch/下获取原生PyTorch的源代码 +## 编译安装PyTorch和昇腾插件 +下载插件代码 ```sh -// 1.5.0 版本 -git clone -b v1.5.0 --depth=1 https://github.com/pytorch/pytorch.git -// 1.8.1 版本 -git clone -b v1.8.1 --depth=1 https://github.com/pytorch/pytorch.git +git clone https://gitee.com/ascend/pytorch.git ``` -进入到pytorch/pytorch/目录下, 获取PyTorch被动依赖代码(获取时间较长,请耐心等待)。 +当前对应PyTorch 1.8.1版本。根据需求,在当前仓库根目录pytorch/下获取原生PyTorch的源代码 ```sh +// 1.8.1 版本 +cd pytorch # 插件根目录 +git clone -b v1.8.1 --depth=1 https://github.com/pytorch/pytorch.git +cd pytorch git submodule sync git submodule update --init --recursive +cd .. ``` -完成且没有报错之后就生成了PyTorch及其依赖的三方代码,然后将Patch打入PyTorch源码。 + +完成且没有报错之后就生成了PyTorch及其依赖的三方代码,然后将Patch打入PyTorch源码并编译。 ```sh -# apply patches. +cd patch +sh apply_patch.sh ../pytorch +cd ../pytorch +sh build.sh ``` -## 编译安装torch_npu +然后安装pytorch/pytorch/dist下生成的torch包,接下来编译安装插件 + +``` +cd ../ci # 进入插件根目录 +sh build.sh +``` +然后安装pytorch/dist下生成的插件torch_npu包 # 运行 diff --git a/test/test_npu.py b/test/test_npu.py index 0b1f000bd4f..26f9a8522e7 100644 --- a/test/test_npu.py +++ b/test/test_npu.py @@ -303,8 +303,9 @@ class TestNpu(TestCase): for dst, try_non_blocking in product(("npu", ), (True, )): # Creates source on the opposite device from destination. src = torch.randn(1000000, - device="npu" if dst == "cpu" else "cpu", - pin_memory=True if dst == "npu" else False) + device="npu" if dst == "cpu" else "cpu") + if dst == "npu": + src = src.pin_memory() _test_to_non_blocking(src, try_non_blocking, dst) def test_to_cpu_blocking_by_default(self): @@ -387,7 +388,6 @@ class TestNpu(TestCase): start_event = torch_npu.npu.Event(enable_timing=True) stream.record_event(start_event) stream.record_event(event) - self.assertFalse(event.query()) event.synchronize() self.assertTrue(event.query()) self.assertGreater(start_event.elapsed_time(event), 0) -- Gitee