k2-fsa / k2

FSA/FST algorithms, differentiable, with PyTorch compatibility.
https://k2-fsa.github.io/k2
Apache License 2.0
1.08k stars 211 forks source link

No module named 'k2.torch_version' #1292

Closed ziax-training-ground closed 3 weeks ago

ziax-training-ground commented 3 weeks ago

Hello! I apologize in advance if someone has already asked such a question, I have already "dug up" everything that I could find and no solutions helped me, specifically on my device, although it still turned out to install everything without problems on another system, but there are newer versions of drivers and cuda. I would be grateful if someone could help me with this issue.

P.S. I also apologize for the bad English

$ python -c "import k2"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/alex/src/k2/k2/python/k2/__init__.py", line 2, in <module>
    from .torch_version import k2_torch_cuda_version
ModuleNotFoundError: No module named 'k2.torch_version'

$ python3 -m k2.version
Traceback (most recent call last):
  File "/usr/lib64/python3.9/runpy.py", line 188, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib64/python3.9/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/home/alex/src/k2/k2/python/k2/__init__.py", line 2, in <module>
    from .torch_version import k2_torch_cuda_version
ModuleNotFoundError: No module named 'k2.torch_version'

$ python3 -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.13.1+cu116
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Fedora Linux 35 (Workstation Edition) (x86_64)
GCC version: (GCC) 11.3.1 20220421 (Red Hat 11.3.1-2)
Clang version: Could not collect
CMake version: version 3.22.2
Libc version: glibc-2.34

Python version: 3.9.12 (main, Mar 25 2022, 00:00:00)  [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] (64-bit runtime)
Python platform: Linux-5.17.5-200.fc35.x86_64-x86_64-with-glibc2.34
Is CUDA available: True
CUDA runtime version: 11.6.124
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3050 Ti Laptop GPU
Nvidia driver version: 510.47.03
cuDNN version: Probably one of the following:
/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudnn.so.8.9.7
/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.9.7
/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.9.7
/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.9.7
/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.9.7
/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.9.7
/usr/local/cuda-11.6/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.9.7
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] k2==1.24.3.dev20230524+cuda11.6.torch1.13.1
[pip3] mypy-extensions==1.0.0
[pip3] numpy==2.0.0
[pip3] torch==1.13.1+cu116
[pip3] torchaudio==0.13.1
[pip3] torchvision==0.14.1
csukuangfj commented 3 weeks ago

Could you tell us in which directory you ran python3 -c import k2?

Could you switch to a different directory, e.g., cd /tmp/, to run python3 -c import k2?

Also please tell us how you installed k2.

ziax-training-ground commented 3 weeks ago

Could you tell us in which directory you ran python3 -c import k2?

[~/src/icefall/] $ ls build docker egs icefall.egg-info pyproject.toml README.md requirements-tts.txt setup.py contributing.md docs icefall LICENSE qweqwe.txt requirements-ci.txt requirements.txt test

Could you switch to a different directory, e.g., cd /tmp/, to run python3 -c import k2?

$cd /tmp

(icefall) [alex@lt-alex-ziax-ru tmp]$ python3 -c "import k2" Traceback (most recent call last): File "", line 1, in File "/home/alex/src/k2/k2/python/k2/init.py", line 2, in from .torch_version import k2_torch_cuda_version ModuleNotFoundError: No module named 'k2.torch_version'

Also please tell us how you installed k2.

I installed according to the instructions located here: https://k2-fsa.github.io/k2/installation/from_wheels.html I installed it taking into account the versions that I could pick up for myself:

$ pip install torch==1.13.1+cu116 -f https://download.pytorch.org/whl/torch_stable.html
$ pip install ./k2-1.24.3.dev20230524+cuda11.6.torch1.13.1-cp39-cp39-linux_x86_64.whl
$ pip install -r requirements.txt  # "~/src/icefall/requirements.txt"
$ pip install torchvision==0.14.1 torchaudio==0.13.1
csukuangfj commented 3 weeks ago

/home/alex/src/k2/k2

Could you tell us why there is such a directory?

File "/home/alex/src/k2/k2/python/k2/__init__.py", line 2, in

The above error shows it is looking for k2 in /home/alex/src/k2/k2/python/k2, not the one you installed.

csukuangfj commented 3 weeks ago

Is /home/alex/src/k2/k2/python on your search path?

Could you show the output of

echo $PYTHONPATH
ziax-training-ground commented 3 weeks ago

Is /home/alex/src/k2/k2/python on your search path?

It's true. I'm blockhead..

I did it by mistake, in one of the wrong attempts to install what I need, and then I didn't fix it. I apologize for the trouble, thank you so much for helping me find the cause of my torment.

csukuangfj commented 3 weeks ago

Great to hear it helps.