Continue Discussion 48 replies
Jul '20

StevenJokes

After run conda activate d2l

# sanity check that the path to the python
# binary matches that of the anaconda env
# after you activate it
which python

To deactivate the environment, either run conda deactivate d2l or exit the terminal. Note that every time you want to work on the assignment, you should rerun conda activate d2l . manage-environments
Reference


only cpu version:
http://preview.d2l.ai/d2l-en/PR-1304/chapter_installation/index.html in my pull


import torch
torch.__version__
torch.cuda.current_device()
torch.cuda.get_device_name(0)

Recommend my repo that records all my study process about pytorch version of d2l-en : https://github.com/StevenJokes/d2l-en-read
Recommend my post: Do these before you ask
More classes:


I still suggest to use conda install to install pytorch

For Chinese users:
In CMD,
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud//pytorch/
Then look https://pytorch.org/get-started/locally/ to install.
For me,

For Chinese users:
It is necessary to use pypi mirror and conda mirror to get pip install and conda install quicker.
pypi mirror:https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
conda mirror:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
For example:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
You can add any other channels

unset pip mirror: pip config unset global.index-url
unset conda mirror:conda config --remove channels

Check your mirror by printing all configuration:
pip config list
conda config --show

conda config --show-sources


For more
增加清华大学镜像源:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
删除默认镜像源:
conda config --remove channels defaults

1 reply
Jul '20

StevenJokes

from d2l import torch as d2l

--------------------------------------------------------------------------- ModuleNotFoundError
Traceback (most recent call last) in
1 get_ipython ( ) . run_line_magic ( ‘matplotlib’ , ‘inline’ ) ---->
2 from
d2l import torch as d2l
3 import torch
4 import random ~\anaconda3\envs\pytorch\lib\site-packages\d2l\torch.py in
17 import tarfile
18 import time
—>19 import requests
20 import zipfile
21 import hashlib
ModuleNotFoundError : No module named ‘requests’


@mli
Is there a way to install all packages advancely we need to import in torch.py or mxnet.py or tensorflow.py?


I guess the reason of No module named ‘requests’ is that mxnet has ‘requests’ defaulty while pytorch not.


d2l requirements
install_requires vs requirements files

1 reply
Aug '20

goldpiggy

hey @StevenJokes, just do a pip install requests.

2 replies
Aug '20 ▶ goldpiggy

StevenJokes

I have done this long long ago. Just curious about how to do all this type stuff advancely.

Have found the solution :conda env create -f environment.yml from handson-ml

Or can we add library “requests” to d2l package?

Aug '20

Shashwat

I have been trying to run these ipynb files of PyTorch but I am getting an error every time I try to run them.

Error is:
Unable to read notebook …ipynb notJSONERROR (notebook does not appear to be json) in Ubuntu.

Could someone help to solve me this error?

3 replies
Aug '20 ▶ Shashwat

goldpiggy

Hi @Shashwat, could specify the Ubuntu version you are using? Is it a local installation without GPU?

1 reply
Aug '20

StevenJokes

@Shashwat

My first search from google: Notebook does not appear to be json · Issue #67 · jupyter/help · GitHub
It may helps you. Can you tell me where do you download there ipynb files?
And more details?


Do you install jupyter?
Maybe you don’t install jupyter book.

Read Project Jupyter | Installing Jupyter. And then you can find these to install jupyter notebook

conda install notebook

or

pip install notebook

Any other problem? Look Do these before you ask! - #11 by StevenJokes. Figure it out by yourself first.


@goldpiggy
I think we don’t tell them to install jupyter at all.
new commit: https://github.com/d2l-ai/d2l-en/pull/1304/commits/198cc5ff657ae15c9c510448ffa73ac8bc19e452
Help me review!

1 reply
Aug '20 ▶ goldpiggy

Shashwat

I am using Ubuntu 18.04 with GTX 1050ti graphics card.

Aug '20 ▶ StevenJokes

Shashwat

Thanks Steven,
I already tried the approaches suggested in https://github.com/jupyter/help/issues/67. But they were of no help. I even tried renaming them with a .html extension but it didn’t help either.

I downloaded the ipynb files from https://d2l.ai/index.html from the All notebooks section.

And yeah I am using Jupyter to run these files.

1 reply
Aug '20 ▶ Shashwat

StevenJokes

I still can’t find your real problem. Have you run other .ipynb that is not in this book files before?
@Shashwat

But there is what you can try:

  1. update your jupyter
  2. read again: https://d2l.ai/chapter_appendix-tools-for-deep-learning/jupyter.html

    Have you run jupyter notebook first, then read files in your browser?
  3. install VScode to open it directly: Using Jupyter
  4. read https://forums.fast.ai/t/unreadable-notebook-home-ubuntu-nbs-lesson1-ipynb-notjsonerror-notebook-does-not-appear-to-be-json/2966/9
    I guess you choose ipynb files from local disk.

Once all packages are installed, you can open the Jupyter notebook by

jupyter notebook

At this point open http://localhost:8888 (which usually opens automatically) in the browser, then you can view and run the code in each section of the book.

from https://tvm.d2l.ai/

Aug '20

StevenJokes

@Shashwat
You’re trying to run the pytorch code that we don’t have now…
Please look this for more details.

Sep '20

kuil

Hello May be it is very easy problem … I have struggled to solve it but I can’t

I installed torch & torch vision CPU only version as book guided

after installation, I activate virtual env & activate Jupyter notebook and run the code of notebook . I also install requests as your guidance

I met error message like this
OSError: [WinError 126] 지정된 모듈을 찾을 수 없습니다.
Error loading “C:~~\torch\lib\asmjit.dll” or one of its dependencies.

Plz give me a guide to fix it.

1 reply
Sep '20

StevenJokes

@kuil

google first… And convert your language to English next time

Sep '20 ▶ Shashwat

TEX

@Shashwat Did you have a solution? I have the same problem like you.
In pytorch folder:

Could someone help me, please?

3 replies
Sep '20 ▶ TEX

StevenJokess

Because there isn’t any code in index…
@TEX

Oct '20

HeartSea15

in my linux, mxnet is cuda-100, why?

image

1 reply
Oct '20 ▶ HeartSea15

StevenJokess

from mxnet import npx plz
click mxnet tab to discuss mxnet next time

Oct '20

HeartSea15

why I cannot import ? thanks reply.
image

**image **

1 reply
Oct '20 ▶ HeartSea15

goldpiggy

Hi @HeartSea15, please post MXNet installation issue under MXNet tag. You may need to upgrade to MXNet 1.7.

Oct '20 ▶ TEX

goopyflux

I got the same error when I tried to run notebooks with .ipynb extension. Looking closely at the files listed, I noticed that several files were 0 B in size. Selecting files with valid size (i.e., which have some content in them) works as expected.

It’s not clear to me why the empty files exist in the first place. Perhaps they can be removed. Hope that helps.

1 reply
Oct '20 ▶ goopyflux

TEX

Thank you, that helps.

So, I think they should add some content to the zero-byte files, in order to avoid these kind of annoyances.

1 reply
Oct '20

goldpiggy

Hey @TEX, does it still bother you? Try git pull origin to pull the latest code may help!

Oct '20

fotis

Hi all! I am also using the pytorch version of the notebooks (downloaded today, 25.Oct.20) and get the error that the notebooks cannot be read. There seem to be two reasons for this, both are bugs in the way the d2l team builds the books. One source of errors is the fact that some notebooks haven’t added the pytorch code yet. Instead of adding a note saying something like ‘not implemented yet’ it just produces a notebook of the size 0. The other source of errors is that those markdown files (which are the source of the notebook files), which don’t have a tag ‘pytorch’ included, are not converted to pytorch notebooks. This includes all index files (and I think generally all files without code). If you have the time, you could fix the first error in the build system (https://github.com/d2l-ai/d2l-book) . The second error needs to be fixed in the markdown files for the book, they need to add a tab all directive there (so I gather from the discussion on the build system). What we can do to get the index files and other text files: copy these files from the mxnet branch. They have no code and work also with the pytorch branch.

1 reply
Nov '20 ▶ fotis

anirudh

Hi @fotis we are working to add the pytorch code blocks for the chapters which are still left. Once those are added the notebook versions of the same will be available.

Probably @mli can shed some light on whether we’ll add a “Not Implemented Yet” mark to the chapters left.

Nov '20

liulei

the solution about “No module named ‘requests’”:

  1. open your anaconda
    2.click botton “Enviroment”
    3.click botton “d2l” (if you have finished Installation’s order ,you will find “d2l” )
    4.select “not installed” and search “requests”(and you will find it on the list)
  2. click “Appliy” botton
    6.reactivate the d2l environment.
1 reply
Mar '21

born_in2020

Hi @goldpiggy I have already done a pip install requests, but the same error is still there :frowning:

1 reply
Mar '21 ▶ liulei

born_in2020

Hi @liulei I installed it with miniconda and I don’t see any button I can click on. Would you please help here? Thanks!

Mar '21 ▶ born_in2020

goldpiggy

Hi @born_in2020, please make sure install requests within the d2l environment (i.e., after you source activate d2l, install it).

Mar '21

Jian_Shi

hi,
I tried pip install d2l, but it still give error that No module named ‘d2l’.

1 reply
Mar '21 ▶ Jian_Shi

StevenJokess


pip install git+https://github.com/d2l-ai/d2l-en
Try this!
@Jian_Shi

Apr '21

Jonathan

Hi, just starting! When installing I’m getting an error that I don’t know what it is.

> pip install torch
Requirement already satisfied: torch in ./miniconda3/envs/d2l/lib/python3.8/site-packages (1.8.1)
Requirement already satisfied: numpy in ./miniconda3/envs/d2l/lib/python3.8/site-packages (from torch) (1.20.2)
Requirement already satisfied: typing-extensions in ./miniconda3/envs/d2l/lib/python3.8/site-packages (from torch) (3.7.4.3)
WARNING: Error parsing requirements for protobuf: [Errno 2] No such file or directory: '/scratch1/user/software/protobuf-3.12.2.dist-info/METADATA'
Mar '23

ZNACloud

For those who encounter an error when installing the d2l package, please see the comments at Error when installing gym==0.21.0 from the setup.py · Issue #2443 · d2l-ai/d2l-en · GitHub

Mar '23

Steven_Kolawole

Hi, as at the time I window-shopped this book months ago, JAX was one of the frameworks listed. But now I can’t find it here again. Is there no longer support for JAX here?

Jul '23

ALEX_EBE

Hello, I’m getting this error when executing pip install d2l==1.0.0b0

Can somebody help please ?

By the way it works well when I don’t specify the version of d2l that I want.

1 reply
Jul '23 ▶ ALEX_EBE

ddplot

Hey, I bumped into the same problem. Looks it’s from this particular version of gym. If you would install a higher 0.22.0 version by running “pip install git+https://github.com/openai/gym.git@0.22.0”, and then run “pip install d2l==1.0.0b0” to continue the d2l installation, the error could be gone. but not sure if the gym of higher version will break the integrity of d2l 1.0.0 itself at some point.

3 replies
Jul '23 ▶ ddplot

ALEX_EBE

Hello!!
Thank you very much. I will try this for sure

Jul '23

gee_gee

If you meet the error “python setup.py egg_info did not run successfully.”, see this question: why-is-pip-install-gym-failing-with-python-setup-py-egg-info-did-not-run-succ

Jul '23 ▶ ddplot

codekunoichi

Thank you for the details; your steps helped resolve this for my similar installation problems.

Aug '23

tylermoseley

This also worked for me, thank you.

Aug '23 ▶ ddplot

loloopes

It helped me a great deal! thx a lot

Aug '23

libing64

image
Great thanks.

Jan '24

DmitriiP20

Are there any plans to add MPS support? I bet a lot of people are reading (at least the early sections) using their Macs, me included

Mar '24

MiracleXYZ

Just run conda deactivate to deactivate the current environment, no need to specify the environment name.

Apr '24

Hon_Shing_Li

Hi, when I type “jupyter notebook” in the command prompt, I did not see any of the course folder in the localhost website. I only see my old ipynb files from past coursework. What should I do?

Dec '24

vijaynyaya

What are the pytorch installation instruction for devices with Intel Arc GPUs?

22 Jan

PlacideKad

I have an issue while installing the d2l package
when i run the command pip install d2l==1.0.3

11 Feb

joseph-pq

Instead of conda, I used uv. Initially I had problems installing torch=2.0.0 such as my Cuda version is 12.2. Thus, I used Python 3.9 with the following dependencies:

requires-python = ">=3.9"
dependencies = [
    "d2l>=1.0.3",
    "torch>=2.6.0",
    "torchaudio>=2.6.0",
    "torchvision>=0.21.0",
]
11 Feb

flayman

Anyone attempting to install d2l into a recent version of python will experience the same problems as PlacideKad above, due to explicit dependencies. Building the binary for the specified version is unlikely to work because of the removal of a deprecated feature in pkgutil. Python 3.12 can use numpy version 1.26+, so until there’s a new release, you can use:

pip install numpy==1.26.4 or pip install "numpy<2" and then install d2l with pip install --no-deps d2l. pip will complain about incompatibilities every time you run it, but the examples may still work. Or they may not. Ideally we would have a release that can work with numpy 2. There has not been a new release since August 2023, which makes me wonder.