Comments (6)
RE 1): Is the build system supposed to work with any installation of PyTorch? e.g. if users build PyTorch from source, or install using Conda
RE 2): Why do we need to replace CudaContext
? I thought we can just create a new class PyTorchContext
which inherits from Context
, then we can operate PyTorch tensor
(no matter GPU or CPU, exposed with DLPack) with current interfaces (e.g. Array1
) and algorithms. Correct me if I'm wrong.
from k2.
It takes several hours to build PyTorch from source. Another problem to build from source is that there is a good chance the PyTorch version K2 uses is different from the one Python uses.
The current CudaContext
is a naive implementation. What I want to do is to change GetCudaContext
so that
it returns a pytorch context
.
I have no experience with conda. But I guess it will work.
from k2.
from k2.
To the best of my knowledge, there are two approaches to build against PyTorch:
(1) Build PyTorch from source. I think only PyTorch developers use this method. The building process can take several hours.
It's very likely that the source version is different from the one installed with pip
.
(2) Build against LibTorch
. https://pytorch.org/ provides links to download libtorch-shared-with-deps-xxx.zip
, which
contains a set of header files and shared/static libraries. These files are also contained in the PyTorch package installed via pip install torch
. pip install torch
is chosen so that we use the same PyTorch version with Python.
cd build/bin
readelf -d cu_array_test
prints
0x0000000000000001 (NEEDED) Shared library: [libfsa.so]
0x0000000000000001 (NEEDED) Shared library: [libgtest_maind.so]
0x0000000000000001 (NEEDED) Shared library: [libtorch.so]
0x0000000000000001 (NEEDED) Shared library: [libtorch_cpu.so]
0x0000000000000001 (NEEDED) Shared library: [libtorch_cuda.so]
0x0000000000000001 (NEEDED) Shared library: [libc10_cuda.so]
0x0000000000000001 (NEEDED) Shared library: [libc10.so]
0x0000000000000001 (NEEDED) Shared library: [libnvToolsExt.so.1]
0x0000000000000001 (NEEDED) Shared library: [libcudart.so.10.0]
0x0000000000000001 (NEEDED) Shared library: [libgtestd.so]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000f (RPATH) Library rpath: [/xxx/pyenv/versions/3.7.8/lib/python3.7/site-packages/torch/lib:/xxx/cuda/lib64:/xxx/cuda/lib64/stubs]
Part of the linking commands for cu_array_test
is given below:
/usr/bin/g++ xxx/array_test.cu.o -o ../../bin/cu_array_test
-Wl,-rpath,/xxx/k2/build/lib:/xxx/pyenv/versions/3.7.8/lib/python3.7/site-packages/torch/lib
/xxx/pyenv/versions/3.7.8/lib/python3.7/site-packages/torch/lib/libtorch.so
-Wl,--no-as-needed,/xxx/pyenv/versions/3.7.8/lib/python3.7/site-packages/torch/lib/libtorch_cpu.so
-Wl,--no-as-needed,/xxx/pyenv/versions/3.7.8/lib/python3.7/site-packages/torch/lib/libtorch_cuda.so
-Wl,--as-needed /xxx/pyenv/versions/3.7.8/lib/python3.7/site-packages/torch/lib/libc10_cuda.so
/xxx/pyenv/versions/3.7.8/lib/python3.7/site-packages/torch/lib/libc10.so
We can see that k2 uses the same PyTorch libraries from the torch package.
Note that there are no restrictions on the PyTorch version. Users can choose which PyTorch version to
use by pip install torch==x.x.x
and K2 will pick the corresponding version correctly.
from k2.
how does your pull request relate to this, in terms of PyTorch versions and compatibility?
Lines 3 to 7 in f784a2c
K2 uses the PyTorch installation information from the pip package, so it's guaranteed that k2 uses whichever version Python
is currently using.
Line 36 in f784a2c
from k2.
from k2.
Related Issues (20)
- Question about k2.union() function. HOT 4
- Installation on Windows with GPU HOT 2
- FST is going down abruptly. HOT 7
- Can not copy k2.RaggedTensor from CPU to GPU by RaggedTensor.to(device_id) HOT 1
- K2 installation is not working (not up to date for the new cuda and pytorch versions) HOT 4
- A warning is always printed when there is an extreme reduction in the encoder output frame rate. HOT 2
- ModuleNotFoundError: No module named '_k2' HOT 2
- Nbest online decoding bug HOT 15
- argmax_internal::PairInputIterator and argmax_internal::PairOutputIterator don't implement the random access iterator concept HOT 6
- ModuleNotFoundError: No module named '_k2' HOT 5
- error: conflicting declaration ‘typedef struct CUevent_st* HOT 7
- nbest C++ api use too much vram HOT 5
- Torchscript export error for torch.finfo function HOT 2
- fail k2.compose(H, LG, inner_labels="tokens") HOT 13
- aux labels id range limit?
- Error during run time in 1st epoch using conformer_ctc2 OTC HOT 1
- I want to install k2 offline , but the log shows that "network is unreachable" HOT 1
- Have problem when installing from source HOT 1
- No module named 'k2.torch_version' HOT 6
- Use k2 to represent regex in decoding
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from k2.