`UnencryptedCookieSessionFactoryConfig` error when importing Apex
Asked Answered
C

6

21

I'm trying to use Apex and whenever I try to import it (or anything involving it) I get the following traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda3/lib/python3.8/site-packages/apex/__init__.py", line 13, in <module>
    from pyramid.session import UnencryptedCookieSessionFactoryConfig
ImportError: cannot import name 'UnencryptedCookieSessionFactoryConfig' from 'pyramid.session' (unknown location)

I have the Pyramid library installed and importing that causes no issues. My Python version is 3.8.5 and my OS is Ubuntu 18.04.5.

I've tried searching online but haven't been able to find a satisfactory solution and was hoping to know if anyone who is familiar would be able to provide some tips on what the problem may be and what I can do. Thanks.

Child answered 13/3, 2021 at 5:21 Comment(2)
It looks like you did not install a compatible version of pyramid into your virtual environment. Apex itself was last uploaded 2013-03-05, and is no longer actively maintained, so I highly doubt it is still compatible with the latest Pyramid 2.0. What do you want to use Apex for? I could suggest alternatives that are maintained, or you can look at trypyramid.com/extending-pyramid.html for add-ons.Computer
Yeah I didn't realize that Apex wasn't being actively maintained. In fact, according to posts on the Discuss PyTorch forum like this one, PyTorch has a native AMP thing as well. I'm not necessarily trying to use Apex, but most of the baseline models that I'm trying to run were implemented using it. I guess I could try refactoring it into PyTorch.Child
C
45

I get the same issue if I use pip install apex.

It turns out that apex on pypi has nothing to do with NVIDIA's apex and is a totally unrelated, really old package.

To install NVIDIA's apex do:

git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir \
--global-option="--cpp_ext" --global-option="--cuda_ext" ./

For more info see doc.

Credent answered 21/4, 2021 at 3:28 Comment(3)
one might face compilation error while installing using git repo as torch currently is using CUDA 10.2 version just sharing the insight which I found during installation. so either downgrade or updgrade to CUDA 10.2 version to make this work.Inexpressible
@AnkitKumarNamdeo, pytorch has a whole variety of builds and not just cu-102, please see: pytorch.org/get-started/locally/#start-locallyCredent
Also if you're using the same major cuda version, but minor versions mismatch, see this workaround: github.com/NVIDIA/apex/issues/988#issuecomment-726343453Credent
A
15

The code below worked for me

git clone https://github.com/NVIDIA/apex
cd apex
python setup.py install
Adaptive answered 16/1, 2022 at 10:8 Comment(0)
K
8

This will work:

pip uninstall apex
Kenakenaf answered 25/8, 2021 at 8:34 Comment(0)
J
2

use apex/requirements.txt
The code below worked for me

git clone https://github.com/NVIDIA/apex
cd apex
pip install -r requirements.txt
pip install -v --disable-pip-version-check --no-cache-dir ./
Joelynn answered 17/1, 2023 at 9:12 Comment(0)
C
1

Below code has worked for me in colab instance

!git clone https://github.com/NVIDIA/apex
%cd apex
!python3 setup.py install
Countryman answered 29/4, 2022 at 10:20 Comment(0)
R
0

Updated March 2023: Created new virtual environment with corrected python version

conda create --name RSSC python==3.7.10
git clone https://github.com/NVIDIA/apex
cd apex
pip install -r requirements.txt
pip install -v --disable-pip-version-check --no-cache-dir ./
Recruit answered 6/3, 2023 at 4:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.