Support for CPU computations and add is_cuda check
When submitting a bug report, please include the following information (where relevant):
- OS: ubuntu 16.04
- How you installed TC (docker, conda, source): conda
- Python version: 3.6
- CUDA/cuDNN version: 9 / 7
- Conda version (if using conda): conda 4.3.30
- Docker image (if using docker): nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
- GCC/GXX version (if compiling from source): 5.4.0
- LLVM/Tapir git hash used (if compiling from source): NA
- Commit hash of our repo and submodules (if compiling from source): NA
TensorComprehensions fail when given CPU tensors (and drops the kernel). Here is an example:
import tensor_co`mprehensions as tc
import torch
lang = """
def fcrelu(float(B,M) I, float(N,M) W1, float(N) B1) -> (O1) {
O1(b, n) +=! I(b, m) * W1(n, m)
O1(b, n) = O1(b, n) + B1(n)
O1(b, n) = fmax(O1(b, n), 0)
}
"""
fcrelu = tc.define(lang, name="fcrelu")
B, M, N = 100, 128, 100
# I, W1, B1 = torch.randn(B, M).cuda(), torch.randn(N, M).cuda(), torch.randn(N).cuda()
I, W1, B1 = torch.randn(B, M), torch.randn(N, M), torch.randn(N)
fcrelu.autotune(I, W1, B1, cache="fcrelu_100_128_100.tc")
out = fcrelu(I, W1, B1)
Result:
WARNING: Logging before InitGoogleLogging() is written to STDERR
W0326 11:57:08.843168 229 rtc.cc:144] Error at: /opt/conda/conda-bld/tensor_comprehensions_1520457708651/work/src/core/rtc.cc:144: CUDA_ERROR_INVALID_CONTEXT
W0326 11:57:08.843502 229 rtc.cc:44] Error at: /opt/conda/conda-bld/tensor_comprehensions_1520457708651/work/src/core/rtc.cc:44: CUDA_ERROR_INVALID_HANDLE
terminate called after throwing an instance of 'std::runtime_error'
what(): Error at: /opt/conda/conda-bld/tensor_comprehensions_1520457708651/work/src/core/rtc.cc:44: CUDA_ERROR_INVALID_HANDLE
It also drops python kernel if you first optimize function and then try to run it with CPU tensors.
PS. Is there a plan to support CPU computations? If not, a simple check like is_cuda should be enough
@arogozhnikov TC indeed does not support CPU atm, this is work in progress.
Hi @arogozhnikov , thanks for reporting. We don't support CPU computations in TC right now. However, adding a simple check for is_cuda() should definitely be possible. I'll re-title this issue to reflect that more properly. Thank you :)