Closed LEECHOONGHO closed 2 years ago
Hi,
Could you install python bindings from source - https://github.com/gtn-org/gtn#python-bindings-from-source
We haven't updated pip with the latest changes to gtn library.
@vineelpratap Thank you for your reply. I have installed gtn and it's python bindings. But when I Tried to test my installation, same error occurs.
/gtn# python -m unittest discover bindings/python/test
......E.....E...............EEE...........F....
======================================================================
ERROR: test_scalar_ops_grad (test_autograd.AutogradTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/leecho/xi-stt/xi-stt/gtn/bindings/python/test/test_autograd.py", line 106, in test_scalar_ops_grad
g2nograd = gtn.scalar_graph(4.0, gtn.Device(gtn.CPU), False)
AttributeError: module 'gtn' has no attribute 'Device'
======================================================================
ERROR: test_device (test_bindings.DeviceTesetCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/leecho/xi-stt/xi-stt/gtn/bindings/python/test/test_bindings.py", line 26, in test_device
self.assertEqual(gtn.Device(gtn.CUDA, 0), gtn.Device(gtn.CUDA, 0))
AttributeError: module 'gtn' has no attribute 'Device'
======================================================================
ERROR: test_scalar_creation (test_creations.CreationsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/leecho/xi-stt/xi-stt/gtn/bindings/python/test/test_creations.py", line 16, in test_scalar_creation
g = gtn.scalar_graph(weight, gtn.Device(gtn.CPU), False)
AttributeError: module 'gtn' has no attribute 'Device'
======================================================================
ERROR: test_criterions (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_criterions
Traceback (most recent call last):
File "/root/anaconda3/envs/xi-stt/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/root/anaconda3/envs/xi-stt/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/home/leecho/xi-stt/xi-stt/gtn/bindings/python/test/test_criterions.py", line 11, in <module>
import gtn.criterion
ModuleNotFoundError: No module named 'gtn.criterion'
======================================================================
ERROR: test_cuda (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_cuda
Traceback (most recent call last):
File "/root/anaconda3/envs/xi-stt/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/root/anaconda3/envs/xi-stt/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/home/leecho/xi-stt/xi-stt/gtn/bindings/python/test/test_cuda.py", line 5, in <module>
class CudaTestCase(unittest.TestCase):
File "/home/leecho/xi-stt/xi-stt/gtn/bindings/python/test/test_cuda.py", line 7, in CudaTestCase
@unittest.skipIf(not gtn.cuda.is_available(), "CUDA not available")
AttributeError: module 'gtn' has no attribute 'cuda'
======================================================================
FAIL: test_equality (test_utils.UtilsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/leecho/xi-stt/xi-stt/gtn/bindings/python/test/test_utils.py", line 120, in test_equality
self.assertFalse(gtn.equal(g1, g2))
AssertionError: True is not false
And I got warning message like below when I execute python setup.py develop
or python setup.py install
CMake Warning (dev) in CMakeLists.txt:
Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
empty CUDA_ARCHITECTURES not allowed. Run "cmake --help-policy CMP0104"
for policy details. Use the cmake_policy command to set the policy and
suppress this warning.
CUDA_ARCHITECTURES is empty for target "gtn".
This warning is for project developers. Use -Wno-dev to suppress it.
cmake version 3.22.2
cuda version 11.5
cudnn version 8.0
OpenSSL 1.1.1m 14 Dec 2021
It seems that there are no modules related to CUDA.
>>> import gtn
>>> dir(gtn)
['Graph', '__builtins__', '__cached__', '__doc__', '__file__',
'__loader__', '__name__', '__package__', '__path__', '__spec__',
'__version__', '_autograd', '_creations', '_functions', '_graph',
'_parallel', '_rand', '_utils', 'add', 'backward', 'clone', 'closure',
'compose', 'concat', 'draw', 'epsilon', 'equal', 'forward_score',
'intersect', 'isomorphic', 'linear_graph', 'load', 'loadtxt', 'negate',
'os', 'parallel_for', 'project_input', 'project_output', 'rand_equivalent',
'remove', 'sample', 'save', 'savetxt', 'scalar_graph', 'subprocess',
'subtract', 'tempfile', 'union', 'viterbi_path', 'viterbi_score', 'write_dot']
Thank you
Hi, I just tried everything in a new environment, and it works for me. Could you please uninstall gtn using pip uninstall gtn
and retry again?
Also, are you using the latest commit from https://github.com/gtn-org/gtn ?
@vineelpratap
Sorry for my late.
I tried to install gtn in docker and when I execute python setup.py install
I got error message like below.
I'm using 8 Tesla T8. How can I change Cmakelist.txt for solving this problem?
-- Build files have been written to: /data/leecho/gtn/bindings/python/build/temp.linux-x86_64-3.8
[ 4%] Performing update step for 'pybind11'
[ 8%] Building CUDA object CMakeFiles/gtn.dir/gtn/cuda/creations.cu.o
[ 8%] Building CUDA object CMakeFiles/gtn.dir/gtn/cuda/compose.cu.o
[ 8%] Building CUDA object CMakeFiles/gtn.dir/gtn/cuda/cuda.cu.o
nvcc fatal : Value 'sm_80' is not defined for option 'gpu-architecture'
nvcc fatal : Value 'sm_80' is not defined for option 'gpu-architecture'
CMakeFiles/gtn.dir/build.make:251: recipe for target 'CMakeFiles/gtn.dir/gtn/cuda/creations.cu.o' failed
make[2]: *** [CMakeFiles/gtn.dir/gtn/cuda/creations.cu.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/gtn.dir/build.make:264: recipe for target 'CMakeFiles/gtn.dir/gtn/cuda/compose.cu.o' failed
make[2]: *** [CMakeFiles/gtn.dir/gtn/cuda/compose.cu.o] Error 1
nvcc fatal : Value 'sm_80' is not defined for option 'gpu-architecture'
CMakeFiles/gtn.dir/build.make:277: recipe for target 'CMakeFiles/gtn.dir/gtn/cuda/cuda.cu.o' failed
make[2]: *** [CMakeFiles/gtn.dir/gtn/cuda/cuda.cu.o] Error 1
CMakeFiles/Makefile2:183: recipe for target 'CMakeFiles/gtn.dir/all' failed
make[1]: *** [CMakeFiles/gtn.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Hi, CUDA is not required for running STC and the criterion run on CPU.
You can add an additional argument to cmake in the setup.py file "-DGTN_BUILD_CUDA=OFF" to disable building CUDA backend.
Thank you for your advice
I finally confirmed the operation of STC.
from model.STCLoss import STC
import random
import torch
from torch.autograd import Variable
stcloss = STC(blank_idx=0, p0=1, plast=1, thalf=1, reduction="none")
batch_size = 2
max_mel_len = 115
max_text_len = 25
num_tokens = 64
inputs = Variable(torch.randn(max_mel_len , batch_size, num_token), requires_grad=True)
targets = [[random.randint(1, max_text_len ) for _ in range(random.randint(1, num_tokens))] for _ in range(batch_size)]
loss = stcloss(inputs, targets)
print(loss)
loss.backward()
tensor(-464.1473, grad_fn=<STCLossFunctionBackward>)
Cool.
Note that STC expects log probabilities as input. You might want to apply logSoftmax(dim=0) on the input before calling stc loss function.
I installed gtn by
pip install gtn
and tested STC like belowBut when I trying to run code like above. The Error Like below occurs.
Is there any way to solve this problem?