openai / jukebox

Code for the paper "Jukebox: A Generative Model for Music"
https://openai.com/blog/jukebox/
Other
7.78k stars 1.4k forks source link

sample.py throws ModuleNotFoundError #46

Open agilebean opened 4 years ago

agilebean commented 4 years ago

Hi, this might be easy to fix, I am just missing a detail in the configuration. After installation without errors, the example code for sampling doesn't run.

python jukebox/sample.py --model=5b_lyrics --name=sample_5b --levels=3 --sample_length_in_seconds=20 --total_sample_length_in_seconds=180 --sr=44100 --n_samples=6 --hop_fraction=0.5,0.5,0.125

throws error:

Traceback (most recent call last):
  File "./sample.py", line 1, in <module>
    import jukebox
ModuleNotFoundError: No module named 'jukebox'

I understand that sample.py is in the jukebox folder, so I need to execute python jukebox/sample.py one level above - but then of course, jukebox cannot be imported. But how is jukebox supposed to be found as module? Doesn't sample.py have to be outside of the jukebox folder?

peterlazzarino commented 4 years ago

have you run the pip install steps? Also are you sure the correct conda environment is activated? It will revert to base if you re-open the console after closing

agilebean commented 4 years ago

@peterlazzarino yes i did all that. in the line import jukebox, is jukebox referring to the folder jukebox or to a module that is installed during the pip install steps?

johndpope commented 4 years ago

Use miniconda - https://docs.conda.io/en/latest/miniconda.html

JohnXenakis2 commented 4 years ago

I am having the similar problem:

Traceback (most recent call last): File "jukebox/sample.py", line 5, in from jukebox.hparams import Hyperparams ModuleNotFoundError: No module named 'jukebox'

Has anyone already solve this?

TimOgden commented 4 years ago

Did you remember to use the command pip install -e . as the last step of the installation? I was having this same issue until I realized that I just forgot to do that last step.

agilebean commented 4 years ago

Did you remember to use the command pip install -e . as the last step of the installation? I was having this same issue until I realized that I just forgot to do that last step.

@TimOgden thanks, that solved the problem - module jukebox is found now.

Unfortunately, I get a new error message now:

python jukebox/sample.py --model=5b_lyrics --name=sample_5b --levels=3 --sample_length_in_seconds=20 \
> --total_sample_length_in_seconds=180 --sr=44100 --n_samples=6 --hop_fraction=0.5,0.5,0.125

Caught error during NCCL init (attempt 0 of 5): Distributed package doesn't have NCCL built in

does this also an installation issue? the nvidia page is not helpful...

febfour commented 4 years ago

@TimOgden I've tried this, but it doesn't help.

I added this to sample.py and it went through, but I don't want to write this stuff.

import sys  
sys.path.append('{absolute path}/jukebox')

and, I got another error.

ModuleNotFoundError: No module named 'mpi4py'

Why can't we import jukebox when they're right in front of us?

When it's this hard to execute, I'm getting tired of it.

febfour commented 4 years ago

I changed A to B and it started to pass.

A : python jukebox/sample.py B : python3 jukebox/sample.py

but, I got an error.

Caught error during NCCL init (attempt 0 of 5): Distributed package doesn't have NCCL built in

hdnh2006 commented 1 year ago

Did you remember to use the command pip install -e . as the last step of the installation? I was having this same issue until I realized that I just forgot to do that last step.

This is the right answer!