blocksparse icon indicating copy to clipboard operation
blocksparse copied to clipboard

Error importing blocksparse

Open safi-manar opened this issue 7 years ago • 5 comments

Hi, I've been trying to install blocksparse on a GCP instance with a P100 GPU, but I have not been able to get past this error. Here's how I did it:

conda install -c anaconda tensorflow-gpu
pip install blocksparse
>>> import blocksparse
>>> from blocksparse.matmul import BlocksparseMatMul
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/johnsmith/anaconda3/envs/temp/lib/python3.6/site-packages/blocksparse/matmul.py", line 13, in <module>
    import blocksparse.ewops as ew
  File "/home/johnsmith/anaconda3/envs/temp/lib/python3.6/site-packages/blocksparse/ewops.py", line 17, in <module>
    _op_module = tf.load_op_library(os.path.join(data_files_path, 'blocksparse_ops.so'))
  File "/home/johnsmith/anaconda3/envs/temp/lib/python3.6/site-packages/tensorflow/python/framework/load_library.py", line 58, in load_op_library
    lib_handle = py_tf.TF_LoadLibrary(library_filename, status)
  File "/home/johnsmith/anaconda3/envs/temp/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: /home/johnsmith/anaconda3/envs/temp/lib/python3.6/site-packages/blocksparse/blocksparse_ops.so: undefined symbol: _ZN10tensorflow20O
pKernelConstruction21CtxFailureWithWarningENS_6StatusE

I also tried this on an AWS p2.xlarge instance, and got the same error.

safi-manar avatar Apr 25 '18 05:04 safi-manar

I thought I would need to use the latest version in order to get the commits you updated, so I cloned the latest version of the repo, and built it from source.

I got the following error:

mkdir -p build
g++ -std=c++11 -O3 -DGOOGLE_CUDA=1 -D_GLIBCXX_USE_CXX11_ABI=1 -I./build -I/usr/local/cuda/include -I/home/user/anaconda3/envs/temp/lib/python3.6/site-packages/tensorflow/include -I/h
ome/user/anaconda3/envs/temp/lib/python3.6/site-packages/tensorflow/include/external/nsync/public -fPIC -c src/blocksparse_kernels.cc -o build/blocksparse_kernels.o
src/blocksparse_kernels.cc: In function ‘tensorflow::Status GetKernel(std::__cxx11::string&, CUfunc_st**)’:
src/blocksparse_kernels.cc:51:29: error: ‘kernel_map_’ was not declared in this scope
     auto kernel_data_pair = kernel_map_.find(kernel_name);
                             ^
Makefile:75: recipe for target 'build/blocksparse_kernels.o' failed
make: * [build/blocksparse_kernels.o] Error 1

by changing the OP Codes in Makefile to:

-arch=sm_30 \
 -gencode=arch=compute_20,code=sm_20 \
 -gencode=arch=compute_30,code=sm_30 \
 -gencode=arch=compute_50,code=sm_50 \
 -gencode=arch=compute_52,code=sm_52 \
 -gencode=arch=compute_60,code=sm_60 \
 -gencode=arch=compute_61,code=sm_61 \
 -gencode=arch=compute_61,code=compute_61

safi-manar avatar Apr 25 '18 05:04 safi-manar

same issue here, error: ‘kernel_map_’ was not declared in this scope

mlzxy avatar May 15 '18 03:05 mlzxy

I found the solution

python generate_kernels.py && make compile

the first command is actually included in the Makefile but it's somehow skipped in my case.

note the ptxas is in /usr/local/cuda-8.0/bin/

mlzxy avatar May 15 '18 04:05 mlzxy

is there a solution that doesn't require building from source?

0x70b1a5 avatar Jul 13 '19 07:07 0x70b1a5

In case this helps anyone: https://github.com/openai/blocksparse/issues/52#issuecomment-752351735

jlozano avatar Dec 30 '20 07:12 jlozano