3

I am running a python 2.7 code (containing GPy and GPyOpt, python implementation of gaussian process and Bayesian optimization) from Matlab on Anaconda 64bit on Windows 10 and I am facing with the following error:

warning in stationary: failed to import cython module: falling back to numpy Error using stationary>_gradients_X_cython (line 323) Python Error: NameError: global name 'stationary_cython' is not defined

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 reasons, I have downgraded the numpy to Numpy=1.11.0. That's because Matlab has a bug with the latest version of Numpy.

Also I am facing with the following window: An application has made an attempt to load the C runtime library ...

Q: Could you please help me to resolve the issue?

    Python Error: NameError: global name 'stationary_cython' is not defined

    Error in stationary>gradients_X (line 236)
            return self._gradients_X_cython(dL_dK, X, X2)

    Error in kernel_slice_operations>wrap (line 118)
            ret = s.handle_return_array(f(self, dL_dK, s.X, s.X2))

    Error in prod>gradients_X (line 80)
            target += self.parts[0].gradients_X(dL_dK*self.parts[1].K(X, 
    X2), X, X2)

   Error in kernel_slice_operations>wrap (line 118)
            ret = s.handle_return_array(f(self, dL_dK, s.X, s.X2))

   Error in gp>predictive_gradients (line 337)
            mean_jac[:,:,i] = 
   kern.gradients_X(self.posterior.woodbury_vector[:,i:i+1].T, Xnew, 
   self._predictive_variable)

   Error in gpmodel>predict_withGradients (line 113)
        dmdx, dvdx = self.model.predictive_gradients(X)

   Error in EI>_compute_acq_withGradients (line 47)
        m, s, dmdx, dsdx = self.model.predict_withGradients(x)

   Error in base>acquisition_function_withGradients (line 46)
        f_acqu,df_acqu = self._compute_acq_withGradients(x)
   Error in LP>d_acquisition_function (line 128)
            _, grad_acq_x = self.acq.acquisition_function_withGradients(x)

Error in LP>acquisition_function_withGradients (line 139)
        aqu_x_grad = self.d_acquisition_function(x)

Error in acquisition_optimizer>fp_dfp (line 165)
            fp_xx , dfp_xx = f_df(xx)

Error in optimizer>_f_df (line 60)
                return f(x), f_df(x)[1][0]

Error in optimize>__call__ (line 63)
        fg = self.fun(x, *args)

Error in optimize>function_wrapper (line 289)
        return function(*(wrapper_args + args))

Error in lbfgsb>func_and_grad (line 278)
            f = fun(x, *args)

Error in lbfgsb>_minimize_lbfgsb (line 330)
                f, g = func_and_grad(x)

Error in lbfgsb>fmin_l_bfgs_b (line 193)
                           **opts)

Error in optimizer>optimize (line 64)
            res = scipy.optimize.fmin_l_bfgs_b(_f_df, x0=x0, bounds=self.space.get_bounds(), maxiter=self.maxiter)

Error in acquisition_optimizer>optimize (line 177)
                x_min, f_min = self.optimizer.optimize(x0, f =fp, df=None, f_df=fp_dfp)

Error in base>optimize (line 59)
            out = self.optimizer.optimize(f=self.acquisition_function, f_df=self.acquisition_function_withGradients)[0]

Error in batch_local_penalization>compute_batch (line 34)
        X_batch = self.acquisition.optimize()

Error in bo>_compute_next_evaluations (line 186)
        return self.evaluator.compute_batch()

Error in bo>run_optimization (line 108)
            self.suggested_sample = self._compute_next_evaluations()

Error in bayesian_optimization>run_optimization (line 458)
        super(BayesianOptimization, self).run_optimization(max_iter = max_iter, max_time = max_time,  eps = eps,
        verbosity=verbosity, save_models_parameters = save_models_parameters, report_file = report_file, evaluations_file=
        evaluations_file, models_file=models_file)

Error in bayesian_optimization>__init__ (line 244)
        self.run_optimization(max_iter=0,verbosity=self.verbosity)

Error in BatchBO>BAYESOPT2 (line 37)
                                                 acquisition_weight = 2)
markalex
  • 8,623
  • 2
  • 7
  • 32
Rayan
  • 31
  • 3
  • I have a similar problem trying to call GPy from R using the R package PythonInR, so it's not just MATLAB. The error I get is: "Runtime Error! Program: C:\Program Files\RStudio\bin\x64\rsession.exe R6034 An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information." – Collin Sep 12 '17 at 20:28

1 Answers1

0

Did you install paramz first? Or did you try installing gcc and gmp in Anaconda?

If your problem goes away when using a Linear Kernel, it seems dependency issues arise due to the Python Package Manager Anaconda.

Source: https://github.com/SheffieldML/GPy/issues/458

Dave Liu
  • 906
  • 1
  • 11
  • 31