Repository: cornellius-gp/gpytorch

Issue:
Installation error
Hi, while installing the package I get the following error. 
```
Collecting git+https://github.com/cornellius-gp/gpytorch.git
Cloning https://github.com/cornellius-gp/gpytorch.git to /tmp/pip-7qp9fn9f-build
Requirement already satisfied: cffi>=1.4.0 in ./.conda/envs/test_env/lib/python3.5/site-packages (from gpytorch==0.1)
Requirement already satisfied: pycparser in ./.conda/envs/test_env/lib/python3.5/site-packages (from cffi>=1.4.0->gpytorch==0.1)
Installing collected packages: gpytorch
  Running setup.py install for gpytorch ... error
    Complete output from command /u/18/gadichs1/unix/.conda/envs/test_env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-7qp9fn9f-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-04cqd2t7-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.5
    creating build/lib.linux-x86_64-3.5/gpytorch
    copying gpytorch/module.py -> build/lib.linux-x86_64-3.5/gpytorch
    copying gpytorch/beta_features.py -> build/lib.linux-x86_64-3.5/gpytorch
    copying gpytorch/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch
    copying gpytorch/settings.py -> build/lib.linux-x86_64-3.5/gpytorch
    creating build/lib.linux-x86_64-3.5/test
    copying test/__init__.py -> build/lib.linux-x86_64-3.5/test
    creating build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/grid_interpolation_kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/linear_kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/additive_grid_interpolation_kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/multiplicative_grid_interpolation_kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/grid_kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/matern_kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/index_kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/spectral_mixture_kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/rbf_kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    copying gpytorch/kernels/periodic_kernel.py -> build/lib.linux-x86_64-3.5/gpytorch/kernels
    creating build/lib.linux-x86_64-3.5/gpytorch/mlls
    copying gpytorch/mlls/exact_marginal_log_likelihood.py -> build/lib.linux-x86_64-3.5/gpytorch/mlls
    copying gpytorch/mlls/marginal_log_likelihood.py -> build/lib.linux-x86_64-3.5/gpytorch/mlls
    copying gpytorch/mlls/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/mlls
    copying gpytorch/mlls/variational_marginal_log_likelihood.py -> build/lib.linux-x86_64-3.5/gpytorch/mlls
    creating build/lib.linux-x86_64-3.5/gpytorch/models
    copying gpytorch/models/abstract_variational_gp.py -> build/lib.linux-x86_64-3.5/gpytorch/models
    copying gpytorch/models/additive_grid_inducing_variational_gp.py -> build/lib.linux-x86_64-3.5/gpytorch/models
    copying gpytorch/models/exact_gp.py -> build/lib.linux-x86_64-3.5/gpytorch/models
    copying gpytorch/models/grid_inducing_variational_gp.py -> build/lib.linux-x86_64-3.5/gpytorch/models
    copying gpytorch/models/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/models
    copying gpytorch/models/variational_gp.py -> build/lib.linux-x86_64-3.5/gpytorch/models
    copying gpytorch/models/gp.py -> build/lib.linux-x86_64-3.5/gpytorch/models
    creating build/lib.linux-x86_64-3.5/gpytorch/functions
    copying gpytorch/functions/dsmm.py -> build/lib.linux-x86_64-3.5/gpytorch/functions
    copying gpytorch/functions/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/functions
    copying gpytorch/functions/log_normal_cdf.py -> build/lib.linux-x86_64-3.5/gpytorch/functions
    copying gpytorch/functions/normal_cdf.py -> build/lib.linux-x86_64-3.5/gpytorch/functions
    copying gpytorch/functions/add_diag.py -> build/lib.linux-x86_64-3.5/gpytorch/functions
    creating build/lib.linux-x86_64-3.5/gpytorch/variational
    copying gpytorch/variational/variational_strategy.py -> build/lib.linux-x86_64-3.5/gpytorch/variational
    copying gpytorch/variational/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/variational
    copying gpytorch/variational/mvn_variational_strategy.py -> build/lib.linux-x86_64-3.5/gpytorch/variational
    creating build/lib.linux-x86_64-3.5/gpytorch/means
    copying gpytorch/means/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/means
    copying gpytorch/means/mean.py -> build/lib.linux-x86_64-3.5/gpytorch/means
    copying gpytorch/means/constant_mean.py -> build/lib.linux-x86_64-3.5/gpytorch/means
    creating build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/constant_mul_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/non_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/interpolated_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/kronecker_product_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/matmul_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/mul_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/toeplitz_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/root_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/sum_batch_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/sum_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/block_diagonal_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/diag_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    copying gpytorch/lazy/psd_sum_lazy_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/lazy
    creating build/lib.linux-x86_64-3.5/gpytorch/likelihoods
    copying gpytorch/likelihoods/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/likelihoods
    copying gpytorch/likelihoods/likelihood.py -> build/lib.linux-x86_64-3.5/gpytorch/likelihoods
    copying gpytorch/likelihoods/bernoulli_likelihood.py -> build/lib.linux-x86_64-3.5/gpytorch/likelihoods
    copying gpytorch/likelihoods/softmax_likelihood.py -> build/lib.linux-x86_64-3.5/gpytorch/likelihoods
    copying gpytorch/likelihoods/gaussian_likelihood.py -> build/lib.linux-x86_64-3.5/gpytorch/likelihoods
    creating build/lib.linux-x86_64-3.5/gpytorch/libfft
    copying gpytorch/libfft/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/libfft
    creating build/lib.linux-x86_64-3.5/gpytorch/random_variables
    copying gpytorch/random_variables/bernoulli_random_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/random_variables
    copying gpytorch/random_variables/dirichlet_random_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/random_variables
    copying gpytorch/random_variables/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/random_variables
    copying gpytorch/random_variables/gaussian_random_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/random_variables
    copying gpytorch/random_variables/samples_random_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/random_variables
    copying gpytorch/random_variables/mixture_random_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/random_variables
    copying gpytorch/random_variables/random_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/random_variables
    copying gpytorch/random_variables/categorical_random_variable.py -> build/lib.linux-x86_64-3.5/gpytorch/random_variables
    creating build/lib.linux-x86_64-3.5/gpytorch/utils
    copying gpytorch/utils/toeplitz.py -> build/lib.linux-x86_64-3.5/gpytorch/utils
    copying gpytorch/utils/linear_cg.py -> build/lib.linux-x86_64-3.5/gpytorch/utils
    copying gpytorch/utils/function_factory.py -> build/lib.linux-x86_64-3.5/gpytorch/utils
    copying gpytorch/utils/fft.py -> build/lib.linux-x86_64-3.5/gpytorch/utils
    copying gpytorch/utils/interpolation.py -> build/lib.linux-x86_64-3.5/gpytorch/utils
    copying gpytorch/utils/__init__.py -> build/lib.linux-x86_64-3.5/gpytorch/utils
    copying gpytorch/utils/sparse.py -> build/lib.linux-x86_64-3.5/gpytorch/utils
    copying gpytorch/utils/stochastic_lq.py -> build/lib.linux-x86_64-3.5/gpytorch/utils
    copying gpytorch/utils/lanczos.py -> build/lib.linux-x86_64-3.5/gpytorch/utils
    copying gpytorch/utils/circulant.py -> build/lib.linux-x86_64-3.5/gpytorch/utils
    creating build/lib.linux-x86_64-3.5/test/kernels
    copying test/kernels/test_rbf_kernel.py -> build/lib.linux-x86_64-3.5/test/kernels
    copying test/kernels/test_additive_kernel.py -> build/lib.linux-x86_64-3.5/test/kernels
    copying test/kernels/test_linear_kernel.py -> build/lib.linux-x86_64-3.5/test/kernels
    copying test/kernels/__init__.py -> build/lib.linux-x86_64-3.5/test/kernels
    copying test/kernels/test_periodic_kernel.py -> build/lib.linux-x86_64-3.5/test/kernels
    creating build/lib.linux-x86_64-3.5/test/functions
    copying test/functions/test_dsmm.py -> build/lib.linux-x86_64-3.5/test/functions
    copying test/functions/__init__.py -> build/lib.linux-x86_64-3.5/test/functions
    copying test/functions/test_log_normal_cdf_test.py -> build/lib.linux-x86_64-3.5/test/functions
    copying test/functions/test_add_diag.py -> build/lib.linux-x86_64-3.5/test/functions
    creating build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/test_root_lazy_variable.py -> build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/test_diag_lazy_variable.py -> build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/test_block_diagonal_lazy_variable.py -> build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/test_constant_mul_lazy_variable.py -> build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/test_toeplizt_lazy_variable.py -> build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/__init__.py -> build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/test_interpolated_lazy_variable.py -> build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/test_kronecker_product_lazy_variable.py -> build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/test_sum_lazy_variable.py -> build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/test_matmul_lazy_variable.py -> build/lib.linux-x86_64-3.5/test/lazy
    copying test/lazy/test_mul_lazy_variable_test.py -> build/lib.linux-x86_64-3.5/test/lazy
    creating build/lib.linux-x86_64-3.5/test/util
    copying test/util/test_fft.py -> build/lib.linux-x86_64-3.5/test/util
    copying test/util/test_cubic_interpolation.py -> build/lib.linux-x86_64-3.5/test/util
    copying test/util/test_linear_cg.py -> build/lib.linux-x86_64-3.5/test/util
    copying test/util/test_lanczos.py -> build/lib.linux-x86_64-3.5/test/util
    copying test/util/__init__.py -> build/lib.linux-x86_64-3.5/test/util
    copying test/util/test_sparse.py -> build/lib.linux-x86_64-3.5/test/util
    copying test/util/test_toeplitz.py -> build/lib.linux-x86_64-3.5/test/util
    copying test/util/test_function_factory.py -> build/lib.linux-x86_64-3.5/test/util
    copying test/util/test_interp.py -> build/lib.linux-x86_64-3.5/test/util
    copying test/util/test_tridiag.py -> build/lib.linux-x86_64-3.5/test/util
    copying test/util/test_circulant.py -> build/lib.linux-x86_64-3.5/test/util
    creating build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_simple_gp_classification.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_kissgp_multiplicative_regression.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_kissgp_variational_regression.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_kissgp_kronecker_product_classification.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_kissgp_kronecker_product_regression.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_kissgp_additive_classification.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_multitask_gp_regression.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_kissgp_additive_regression.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_kissgp_gp_regression.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_kissgp_gp_classification.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/__init__.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_spectral_mixture_gp_regression.py -> build/lib.linux-x86_64-3.5/test/examples
    copying test/examples/test_simple_gp_regression.py -> build/lib.linux-x86_64-3.5/test/examples
    running build_ext
    generating cffi module 'build/temp.linux-x86_64-3.5/gpytorch.libfft._libfft.c'
    creating build/temp.linux-x86_64-3.5
    building 'gpytorch.libfft._libfft' extension
    creating build/temp.linux-x86_64-3.5/build
    creating build/temp.linux-x86_64-3.5/build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/tmp
    creating build/temp.linux-x86_64-3.5/tmp/pip-7qp9fn9f-build
    creating build/temp.linux-x86_64-3.5/tmp/pip-7qp9fn9f-build/gpytorch
    creating build/temp.linux-x86_64-3.5/tmp/pip-7qp9fn9f-build/gpytorch/csrc
    gcc -pthread -B /u/18/gadichs1/unix/.conda/envs/test_env/compiler_compat -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/u/18/gadichs1/unix/.conda/envs/test_env/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include -I/u/18/gadichs1/unix/.conda/envs/test_env/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/TH -I/u/18/gadichs1/unix/.conda/envs/test_env/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC -I/u/18/gadichs1/unix/.conda/envs/test_env/include/python3.5m -c build/temp.linux-x86_64-3.5/gpytorch.libfft._libfft.c -o build/temp.linux-x86_64-3.5/build/temp.linux-x86_64-3.5/gpytorch.libfft._libfft.o -std=c99
    gcc -pthread -B /u/18/gadichs1/unix/.conda/envs/test_env/compiler_compat -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/u/18/gadichs1/unix/.conda/envs/test_env/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include -I/u/18/gadichs1/unix/.conda/envs/test_env/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/TH -I/u/18/gadichs1/unix/.conda/envs/test_env/lib/python3.5/site-packages/torch/utils/ffi/../../lib/include/THC -I/u/18/gadichs1/unix/.conda/envs/test_env/include/python3.5m -c /tmp/pip-7qp9fn9f-build/gpytorch/csrc/fft.c -o build/temp.linux-x86_64-3.5/tmp/pip-7qp9fn9f-build/gpytorch/csrc/fft.o -std=c99
    /tmp/pip-7qp9fn9f-build/gpytorch/csrc/fft.c:2:19: fatal error: fftw3.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/u/18/gadichs1/unix/.conda/envs/test_env/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-7qp9fn9f-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-04cqd2t7-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-7qp9fn9f-build/
```
I'm on Ubuntu 16.04, here is my conda list. 
```
# Name                    Version                   Build  Channel
ca-certificates           2018.1.18                     0    conda-forge
certifi                   2018.1.18                py35_0    conda-forge
cffi                      1.11.5                   py35_0    conda-forge
cudatoolkit               8.0                           3  
cudnn                     7.0.5                 cuda8.0_0  
fftw                      3.3.7                         0    conda-forge
freetype                  2.8.1                         0    conda-forge
intel-openmp              2018.0.0             hc7b2577_8  
jpeg                      9b                            2    conda-forge
libedit                   3.1                  heed3624_0  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 7.2.0                hdf63c60_3  
libgfortran-ng            7.2.0                hdf63c60_3  
libpng                    1.6.34                        0    conda-forge
libstdcxx-ng              7.2.0                hdf63c60_3  
libtiff                   4.0.9                         0    conda-forge
mkl                       2018.0.1             h19d6760_4  
ncurses                   6.0                  h9df7e31_2  
numpy                     1.14.2           py35hdbf6ddf_0  
olefile                   0.45.1                   py35_0    conda-forge
openssl                   1.0.2n                        0    conda-forge
pillow                    5.0.0                    py35_0    conda-forge
pip                       9.0.2                     <pip>
pip                       9.0.1                    py35_5  
pycparser                 2.18                     py35_0    conda-forge
python                    3.5.5                hc3d631a_1  
pytorch                   0.3.1           py35_cuda8.0.61_cudnn7.0.5_2    pytorch
readline                  7.0                  ha6073c6_4  
setuptools                39.0.1
setuptools                38.5.1                   py35_0  
six                       1.11.0                   py35_1    conda-forge
sqlite                    3.22.0               h1bed415_0  
tk                        8.6.7                hc745277_3  
torchvision               0.2.0                     <pip>
torchvision               0.2.0                    py35_0    conda-forge
wheel                     0.30.0           py35hd3883cf_1  
xz                        5.2.3                h55aa19d_2  
zlib                      1.2.11               ha838bed_2  
```
The gcc version currently is 
```
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

Any help is really appreciated.


Discussion:
Since you are on Ubuntu, could you try installing fftw via `apt-get`? I think the package names are `libfftw3-3` and `libfftw3-dev`, but it might find them if you just try `fftw3`. 

I can look further at what the package name is when I'm actually in front of a computer if none of those work :-).

@gpleiss I think I've run in to this issue, I'm not actually totally convinced that installing fftw from conda works every time.
Problem solved after installing `libfftw3-3` and `libfftw3-dev`. But I used `aptdcon` instead of `apt-get` as I'm on university desktop. 

Thanks for the suggestion!

Resolving patch:
diff --git a/build.py b/build.py
--- a/build.py
+++ b/build.py
@@ -1,13 +1,20 @@
 import os
+import sys
 import torch
 from torch.utils.ffi import create_extension
 
+# Get the anaconda directory, if applicable
+conda_directory = os.path.join(os.path.dirname(os.path.dirname(sys.executable)))
+conda_lib = os.path.join(conda_directory, 'lib')
+conda_include = os.path.join(conda_directory, 'include')
+
 headers = ['gpytorch/csrc/fft.h']
 sources = ['gpytorch/csrc/fft.c']
 defines = []
 with_cuda = False
 libraries = ['fftw3']
-library_dirs = ['/usr/local/lib', '/usr/local/include']
+library_dirs = [conda_lib, '/usr/local/lib']
+include_dirs = [conda_include, '/usr/local/include']
 
 if torch.cuda.is_available():
     cuda_home = os.getenv('CUDA_HOME') or '/usr/local/cuda'
@@ -29,6 +36,7 @@
     define_macros=defines,
     libraries=libraries,
     library_dirs=library_dirs,
+    include_dirs=include_dirs,
     with_cuda=with_cuda,
     package=True,
     extra_compile_args=["-std=c99"],


Test patch: