-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue when calling gp.predictive_gradients() #458
Comments
Hmm this seems odd, indeed. If the cython module is missing, it should never get into that part of the if statement. As you can see above in the same file, it should write into the config, that cython is not available. as a sanity check could you try putting [cython] in your %userprofile%\.config\GPy\user.cfg file and rerun the script? I am more bamboozled about the fact, that cython is not working for you. We build the cython modules for windows and upload them to pypi, so it should install on windows without problems. Have you installed the cython module using anaconda? |
Hi Max, I actually re-installed Anaconda this morning to sanity check a few things, I don't recall explicitly installing cython so I'm not sure whether it was already there or pip took care of it. Nevertheless, I currently have cython v0.25.1 installed according to conda. With the above flag in the user.cfg file I get the same errors,
|
Does the following report False?
|
It reports True. |
can you import
? |
No, I get the following error:
|
So the config reports True, although you have given cython working as false? This is getting more odd by the minute. Are you able to import cython? On another note, the gradient computation for the ARD parameters makes use of cython, too. What happens if you use an ARD kernel:
and run a normal GP as you described above, without the predictive gradients? |
Hmmm, I can import cython with no errors. To double check I ran the cython hello world example here. When I first ran this tutorial there was an "Unable to find vcvarsall.bat" error which I have now resolved. Without the predictive gradients, i.e., running the following code:
I get the following output:
If I usethe RBF kernel with ARD=True, then the code fails again with a similar output to before:
|
So you said you are using your own compiler. Can you download the source and run the setup code from the source directory with your compiler directly? That should compile the resources directly and make everything work. You might have to look up the compilation options for the setup script (i only know the two options --compiler=msvc or mingw, not sure about tdm). I think we have brought it down to the compilation, though. It might be windows 7, which is the most likely to me, but the compiled version seems to not work for you :( |
Hmmm, I've tried to install GPy from source. I uninstalled GPy using pip, then downloaded the source and ran 'python setup.py install' from the source directory with distutils.cfg pointing to msvc (I have that installed as well) and still ended up with the same errors when running the above scripts. Am I missing anything here? Thanks for your help so far. |
It seems the compilation is not working. You should be able to still use the numpy code by providing cython working = false in the config. Unfortunately I do not have Windows and cannot go deeper, I am afraid :/
|
I provided cython working = False but that didn't help. This morning I uninstalled 64bit Anaconda and installed 32bit Anaconda and everything now works fine. It must be a 64bit compiler issue as I mentioned in the first post. I am not sure whether I am being naive or whether there is a bug with respect to the cython working = False as that seems to not have the desired effect on my machine. Either way, I now have a work around and at least this issue Anaconda 64bit on windows is documented here in case anyone else comes across it. Thanks for your time and help with this. |
On the contrary, thanks for reporting and using GPy!
|
I'm still getting the same error. Also, I don't want to change everything to use 32-bit version. @blaahhrrgg The reason why cython is still True is because during import process, I removed all these lines, and was able to run your commands without errors |
Hi!
When I run the code in python I do not have any problem, but the problem comes when I call the script from MATLAB (I have run the code from MATLAB a few months ago without any problem.) I have to mention, recently for some reason, I have downgraded the numpy to Numpy=1.11.0. Also I am facing with the following window: Could you please help me to resolve the issue?
|
I am facing the following issue. I am using python 2.7 and anaconda 32bit. NameErrorTraceback (most recent call last) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\methods\bayesian_optimization.pyc in init(self, f, domain, constrains, cost_withGradients, model_type, X, Y, initial_design_numdata, initial_design_type, acquisition_type, normalize_Y, exact_feval, acquisition_optimizer_type, model_update_interval, evaluator_type, batch_size, num_cores, verbosity, verbosity_model, bounds, maximize, **kwargs) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\methods\bayesian_optimization.pyc in run_optimization(self, max_iter, max_time, eps, verbosity, save_models_parameters, report_file, evaluations_file, models_file, **kwargs) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\core\bo.pyc in run_optimization(self, max_iter, max_time, eps, verbosity, save_models_parameters, report_file, evaluations_file, models_file) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\core\bo.pyc in _compute_next_evaluations(self) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\core\evaluators\sequential.pyc in compute_batch(self) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\acquisitions\base.pyc in optimize(self) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\optimization\acquisition_optimizer.pyc in optimize(self, f, df, f_df) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\optimization\optimizer.pyc in optimize(self, x0, f, df, f_df) C:\ProgramData\Anaconda2\lib\site-packages\scipy\optimize\lbfgsb.pyc in fmin_l_bfgs_b(func, x0, fprime, args, approx_grad, bounds, m, factr, pgtol, epsilon, iprint, maxfun, maxiter, disp, callback, maxls) C:\ProgramData\Anaconda2\lib\site-packages\scipy\optimize\lbfgsb.pyc in _minimize_lbfgsb(fun, x0, args, jac, bounds, disp, maxcor, ftol, gtol, eps, maxfun, maxiter, iprint, callback, maxls, **unknown_options) C:\ProgramData\Anaconda2\lib\site-packages\scipy\optimize\lbfgsb.pyc in func_and_grad(x) C:\ProgramData\Anaconda2\lib\site-packages\scipy\optimize\optimize.pyc in function_wrapper(*wrapper_args) C:\ProgramData\Anaconda2\lib\site-packages\scipy\optimize\optimize.pyc in call(self, x, *args) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\optimization\optimizer.pyc in _f_df(x) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\optimization\acquisition_optimizer.pyc in fp_dfp(x) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\acquisitions\base.pyc in acquisition_function_withGradients(self, x) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\acquisitions\EI.pyc in _compute_acq_withGradients(self, x) C:\ProgramData\Anaconda2\lib\site-packages\GPyOpt\models\gpmodel.pyc in predict_withGradients(self, X) C:\ProgramData\Anaconda2\lib\site-packages\GPy\core\gp.pyc in predictive_gradients(self, Xnew, kern) C:\ProgramData\Anaconda2\lib\site-packages\GPy\kern\src\kernel_slice_operations.pyc in wrap(self, dL_dK, X, X2) C:\ProgramData\Anaconda2\lib\site-packages\GPy\kern\src\stationary.pyc in gradients_X(self, dL_dK, X, X2) C:\ProgramData\Anaconda2\lib\site-packages\GPy\kern\src\stationary.pyc in _gradients_X_cython(self, dL_dK, X, X2) NameError: global name 'stationary_cython' is not defined |
I was having a similar issue, which seems to be caused by not having gcc and gmp installed in Conda. I was able to use: To install the necessary libraries, and then I ran: |
Maybe you need to install paramz first, and then GPy, and then finally GPyOpt. I had a similar issue but now I don't get the error message: |
I was still getting the "unable to load cython" error now (Nov 2019), with GPy installed on python 2.7 from pip. I can run everything fine, but runtime seems excessively slow. I suspect that this is due to using the numpy rather than cython version of things. I solved this by installing the Microsoft Visual C++ redistributable 2008 SP1 (example here). My guess is that the cythonized files in the GPy package were compiled with this version of MSVC. This is kind of an old version, and newer Windows machines (e.g. fresh install of Windows 10) do not come with all of the redistributables for older MSVC++. The "side-by-side configuration error" is caused by not having the correct version of the MSVC++ redistributables on your system (or windows being unable to find them). To the maintainers: I would suggest including this (i.e. the required MSVC++ redistributable version) in the error message when the cython libraries fail to load due to a side-by-side configuration error. |
I am running Python v2.7.12 using Anaconda 64bit on Windows 7. I installed GPy using 'pip install GPy' to get version 1.5.6 which I have been using for a while on small problems without any issues. More, recently I have wanted to make use of the predictive_gradients() function but I have run into some issues.
Firstly, when I import GPy I get the following warning: "warning in stationary: failed to import cython module: falling back to numpy" which I have not thought too much of in the past since everything else seemed to work okay. Secondly, when I try and run the following code,
I get the following error,
If I use a linear kernel I do not get the above error.
I wondered if this was related to the documented issues on using cython code with anaconda on Windows 64bit due to bundling with mingw64 (see: ContinuumIO/anaconda-issues#175) but I am now using TDM-GCC and the issue persists.
Has this been documented before? Is there anything I have missed that I can try to get this to work?
Many thanks for your help.
The text was updated successfully, but these errors were encountered: