AttributeError: module 'torch._C' has no attribute 'ExtraFilesMap'

Frozen: <p>AttributeError: module ‘torch._C’ has no attribute ‘ExtraFilesMap’</p>
<p>Hi,everyone,I was in trouble with the compilation from pytorch source code cloned from master branch, during the compilation, there was <strong>no error</strong>, but after the compilation, trying to <em>import torch</em> from python interpreter raise an error:</p>
<pre><code class="lang-python">&gt;&gt;&gt; import torch
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/local/lib/python3.6/site-packages/torch/__init__.py", line 478, in &lt;module&gt;
    import torch.nn.quantized
  File "/usr/local/lib/python3.6/site-packages/torch/nn/quantized/__init__.py", line 6, in &lt;module&gt;
    from .modules import *
  File "/usr/local/lib/python3.6/site-packages/torch/nn/quantized/modules/__init__.py", line 9, in &lt;module&gt;
    from .conv import Conv1d, Conv2d, Conv3d
  File "/usr/local/lib/python3.6/site-packages/torch/nn/quantized/modules/conv.py", line 16, in &lt;module&gt;
    from torch._ops import ops
  File "/usr/local/lib/python3.6/site-packages/torch/_ops.py", line 9, in &lt;module&gt;
    import torch.jit
  File "/usr/local/lib/python3.6/site-packages/torch/jit/__init__.py", line 133, in &lt;module&gt;
    DEFAULT_EXTRA_FILES_MAP = torch._C.ExtraFilesMap()
AttributeError: module 'torch._C' has no attribute 'ExtraFilesMap'

</code></pre>
<p>PS: the compilation is completed in a running docker container (ubuntu16.04, cuda10.0, cudnn7.6.5, RTX2070 graphic card on the host machine, gpu driver 418.39)</p>

<h2>To Reproduce</h2>
<p>Steps to reproduce the behavior:</p>
<ol>
<li>conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses</li>
<li>USE_CUDNN=1  python setup.py install</li>
<li>import torch from python interpreter</li>
</ol>

<h2>Expected behavior</h2>
<p>AttributeError: module ‘torch._C’ has no attribute ‘ExtraFilesMap’</p>

<h2>Environment</h2>
<ul>
<li>PyTorch Version (e.g., 1.0):1.7.0a0</li>
<li>OS (e.g., Linux): 16.04.1-Ubuntu</li>
<li>How you installed PyTorch (<code>conda</code>, <code>pip</code>, source): source</li>
<li>Build command you used (if compiling from source):</li>
</ul>
<ol>
<li>
<p>conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses</p>
</li>
<li>
<p>USE_CUDNN=1  python setup.py install</p>
</li>
</ol>
<ul>
<li>
<p>Python version: 3.6.10</p>
</li>
<li>
<p>CUDA/cuDNN version: 10.0, V10.0.130/7.6.5</p>
</li>
<li>
<p>GPU models and configuration: RTX2070, driver 418.39</p>
</li>
<li>
<p>Any other relevant information:</p>
<p>compilation is done in a running docker container started with nvidia-docker.</p>
</li>
</ul>
<h2>Additional context</h2>

<p>below is my Dockerfile for building the docker image I use.</p>
<pre><code class="lang-auto">FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu16.04


RUN apt-get clean &amp;&amp; \
    rm -rfv /var/lib/apt/lists/* &amp;&amp; apt-get clean

RUN apt-get update &amp;&amp; \
		apt-get install -y software-properties-common

RUN apt-get update --fix-missing &amp;&amp; apt-get install -y --no-install-recommends --allow-unauthenticated \
		libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev \
		build-essential \
        software-properties-common \
        curl \
        cmake \
        libfreetype6-dev \
        libpng12-dev \
        libzmq3-dev \
        pkg-config \
        rsync \
        zip \
        unzip \
        git \
        wget \
        vim \
        openssh-server \
        openssl libssl-dev \
        ca-certificates \
        apt-utils libsm6 libxrender1 libxext-dev libglib2.0-0 \
        language-pack-zh-hans \
        &amp;&amp; \
        apt-get update --allow-unauthenticated &amp;&amp; apt-get install libsndfile1 -y &amp;&amp; \
    apt-get clean &amp;&amp; \
    rm -rf /var/lib/apt/lists/*

# configure python 3.6.10
ADD python-3.6.10.tar /python_build
RUN cd /python_build/Python-3.6.10 \
	&amp;&amp; ./configure &amp;&amp; make &amp;&amp; make install

# update pip
# RUN python3.6 -m pip install pip --upgrade &amp;&amp; \
#         python3.6 -m pip install wheel

RUN ln -s $(which python3) /usr/bin/python &amp;&amp; \
	ln -s $(which pip3) /usr/local/bin/pip &amp;&amp; pip install --upgrade pip &amp;&amp; pip install wheel

RUN python -V &amp;&amp; pip -V &amp;&amp; rm -rfv /python_build

# Chinese Charactors support
RUN apt-get install -y locales \
    &amp;&amp; localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8


ENV LC_ALL=en_US.UTF-8
ENV LANG=LANG=zh_CN.UTF-8
ENV PYTHONIOENCODING=utf-8
ENV PYTHONPATH=/usr/src/app
ENV TZ=Asia/Shanghai

# CUDA environment
ENV PATH /usr/local/cuda/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/cuda/lib64:$LD_LIBRARY_PATH
</code></pre>
<p>the <a href="https://www.python.org/downloads/release/python-3610/" rel="nofollow noopener">link</a> to the python3.6.10 source code.</p>

ptrblck: <p>Is your work directory in the PyTorch source code dir? If so, could you change it to another workspace?<br>
I would recommend to clean the build (via <code>python setup.py clean</code>), update all submodules and rebuild.</p>
<p>Your <code>Dockerfile</code> doesn’t show the PyTorch installation, which would be interesting to see.</p>

Frozen: <p>Thanks for the reply.<br>
My work directory is <code>~</code>, and my pytorch directory is under /pytorch_build,<br>
I did <code>python setup.py clean</code> but still the same error.</p>
<p>there’s no <code>Dockerfile</code> for pytorch building yet, I just run a container and did all the compilation in it using the image built from the <code>Dockerfile</code> above</p>

Frozen: <p>My fault, I run <code>pip install -r requirements.txt</code> before the compilation though I removed <code>torch</code> and <code>torchvision</code> indeed, I forgot to remove <code>pytorch-ignite</code> which installed <code>torch 1.6.0</code>.<br>
The code <code>DEFAULT_EXTRA_FILES_MAP = torch._C.ExtraFilesMap()</code> exist only in an older version of pytorch aka 1.6.0 and before and somehow the building procedure didn’t remove it.</p>