Unverified Commit a78ccf0b authored by Shoufa Chen's avatar Shoufa Chen Committed by GitHub
Browse files

fix import container_abcs issue (#1049)

* copy-paste friendly

* fix import container_abcs issue

Nightly PyTorch has removed `container_abcs` from `torch._six`.  https://github.com/pytorch/pytorch/commit/58eb23378f2a376565a66ac32c93a316c45b6131#diff-b3c160475f0fbe8ad50310f92d3534172ba98203387a962b7dc8f4a23b15cf4dL35

* fix import container_abcs issue

Nightly PyTorch has removed `container_abcs` from `torch._six`.
https://github.com/pytorch/pytorch/commit/58eb23378f2a376565a66ac32c93a316c45b6131#diff-b3c160475f0fbe8ad50310f92d3534172ba98203387a962b7dc8f4a23b15cf4dL35

* keep existing for pytorch1.7 and earlier
parent eefb1ba2
...@@ -122,14 +122,14 @@ See the [Docker example folder](https://github.com/NVIDIA/apex/tree/master/examp ...@@ -122,14 +122,14 @@ See the [Docker example folder](https://github.com/NVIDIA/apex/tree/master/examp
For performance and full functionality, we recommend installing Apex with For performance and full functionality, we recommend installing Apex with
CUDA and C++ extensions via CUDA and C++ extensions via
``` ```
$ git clone https://github.com/NVIDIA/apex git clone https://github.com/NVIDIA/apex
$ cd apex cd apex
$ pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./ pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
``` ```
Apex also supports a Python-only build (required with Pytorch 0.4) via Apex also supports a Python-only build (required with Pytorch 0.4) via
``` ```
$ pip install -v --disable-pip-version-check --no-cache-dir ./ pip install -v --disable-pip-version-check --no-cache-dir ./
``` ```
A Python-only build omits: A Python-only build omits:
- Fused kernels required to use `apex.optimizers.FusedAdam`. - Fused kernels required to use `apex.optimizers.FusedAdam`.
......
...@@ -8,10 +8,11 @@ import torch ...@@ -8,10 +8,11 @@ import torch
TORCH_MAJOR = int(torch.__version__.split('.')[0]) TORCH_MAJOR = int(torch.__version__.split('.')[0])
TORCH_MINOR = int(torch.__version__.split('.')[1]) TORCH_MINOR = int(torch.__version__.split('.')[1])
if TORCH_MAJOR == 0:
import collections.abc as container_abcs if TORCH_MAJOR == 1 and TORCH_MINOR < 8:
else:
from torch._six import container_abcs from torch._six import container_abcs
else:
import collections.abc as container_abcs
class AmpState(object): class AmpState(object):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment