hughperkins / pytorch

Python wrappers for torch and lua
BSD 2-Clause "Simplified" License
431 stars 70 forks source link

CMake Warning at CMakeLists.txt:48 (FIND_PACKAGE): #36

Closed ahmedmazari closed 7 years ago

ahmedmazari commented 7 years ago

Hello, My error is related to line 48 from this file code https://github.com/SeanNaren/warp-ctc/blob/pytorch_bindings/CMakeLists.txt

After installing pytorch corrctly. l want to install the Fast parallel CTC https://github.com/SeanNaren/warp-ctc l started installing as follow :

git clone https://github.com/baidu-research/warp-ctc.git
cd warp-ctc
mkdir build
cd build

then l stacked at the (cmake command)

cmake ../

-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found CUDA: /usr/local/cuda (found suitable version "8.0", minimum required is "6.5") 
-- cuda found TRUE
_**CMake Warning at CMakeLists.txt:48 (FIND_PACKAGE):
  By not providing "FindTorch.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Torch", but
  CMake did not find one.

  Could not find a package configuration file provided by "Torch" with any of
  the following names:

    TorchConfig.cmake
    torch-config.cmake

  Add the installation prefix of "Torch" to CMAKE_PREFIX_PATH or set
  "Torch_DIR" to a directory containing one of the above files.  If "Torch"
  provides a separate development package or SDK, be sure it has been
  installed.**_

-- Torch found Torch_DIR-NOTFOUND
-- Building shared library with GPU support
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ahmed/Downloads/warp-ctc/build

l don't understand the error :

**"_CMake Warning at CMakeLists.txt:48 (FIND_PACKAGE): By not providing "FindTorch.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Torch", but CMake did not find one.

Could not find a package configuration file provided by "Torch" with any of the following names:

TorchConfig.cmake
torch-config.cmake

Add the installation prefix of "Torch" to CMAKE_PREFIX_PATH or set "Torch_DIR" to a directory containing one of the above files. If "Torch" provides a separate development package or SDK, be sure it has been installed. "**

zhanghang1989 commented 7 years ago

Hi @ahmedmazari , have you solved this problem? Thanks!

ahmedmazari-dhatim commented 7 years ago

@zhanghang1989 , Yes l did. Let me know if you still encounter the same problem to post the steps that allowed me to solve the problem

zhanghang1989 commented 7 years ago

Thanks @ahmedmazari ! I did a hacky way by manually set the path. Let me know if there is a better solution! Thanks again

set(TORCH_BUILD_DIR "/anaconda/lib/python3.6/site-packages/torch/lib")

# Find the include files
set(TORCH_TH_INCLUDE_DIR "${TORCH_BUILD_DIR}/include/TH")
set(TORCH_THC_INCLUDE_DIR "${TORCH_BUILD_DIR}/include/THC")
set(TORCH_THC_UTILS_INCLUDE_DIR "$ENV{HOME}/pytorch/torch/lib/THC")

set(Torch_INSTALL_INCLUDE "${TORCH_BUILD_DIR}/include" ${TORCH_TH_INCLUDE_DIR} ${TORCH_THC_INCLUDE_DIR} ${TORCH_THC_UTILS_INCLUDE_DIR})

# Find the libs. We need to find libraries one by one.
set(TORCH_LIB_HINTS "${TORCH_BUILD_DIR}" "/usr/local/lib" "/root/torch/install/lib")
find_library(THC_LIBRARIES NAMES THC THC.1 PATHS ${TORCH_BUILD_DIR} PATH_SUFFIXES lib)
find_library(TH_LIBRARIES NAMES TH TH.1 PATHS ${TORCH_BUILD_DIR} PATH_SUFFIXES lib)
ahmedmazari-dhatim commented 7 years ago

Hi @zhanghang1989 , you're welcome The problem is related to cuda and cudnn . you have to update first torch then install cudnn. Before :
be sure that you have gcc 4.9 or 4.8 installed Do the following :

luarocks install torch
luarocks install nn
luarocks install cutorch
luarocks install cunn

If doesn't work downgrade your gcc to 4.9 and try again .

Please et me know if it works

ZmeiGorynych commented 6 years ago

I ran into the same issue, none of the above suggestions worked, but I could fix it by installing both pytorch AND torch (the latter from from http://torch.ch/docs/getting-started.html) from source, then installing warp-ctc as per the instructions at https://github.com/SeanNaren/warp-ctc

chrjxj commented 5 years ago

Got the same issue.

Solution: export Torch_DIR as env variable before cmake

e.g. i am using python virtual env on linux, and installed pytorch using 'pip'.

export Torch_DIR=/home/my/pyenv/py3.7-torch1.0/lib/python3.7/site-packages/torch/share/cmake/Torch

cmake blablabla
make