cvxgrp / scs

Splitting Conic Solver
MIT License
553 stars 136 forks source link

NotImplementedError when using SCS with GPU #222

Open hassanis opened 2 years ago

hassanis commented 2 years ago

Specifications

Description

I'm trying to use SCS using the GPU. I am using it along with CVXPY. When solving on CPU, I encounter no problems. When I add the parameter "gpu" = True, I encounter the following error: "NotImplementedError: GPU direct solver not yet available, passuse_indirect=True."

How to reproduce

I installed SCS using the steps in the documentation:

git clone --recursive https://github.com/bodono/scs-python.git
cd scs-python
python setup.py install --scs --gpu

installation was able to complete.

I have CUDA installed and an environment variable "CUDA_PATH" pointing to its directory.

Additional information

While I understand that CPU may be faster, I am hoping to integrate SCS in an end to end learning framework that is on the GPU.

Output

File ~\anaconda3\lib\site-packages\cvxpy\problems\problem.py:473, in Problem.solve(self, *args, **kwargs)
    471 else:
    472     solve_func = Problem._solve
--> 473 return solve_func(self, *args, **kwargs)

File ~\anaconda3\lib\site-packages\cvxpy\problems\problem.py:975, in Problem._solve(self, solver, warm_start, verbose, gp, qcp, requires_grad, enforce_dpp, **kwargs)
    971     s.LOGGER.info(
    972             'Invoking solver %s  to obtain a solution.',
    973             solving_chain.reductions[-1].name())
    974 start = time.time()
--> 975 solution = solving_chain.solve_via_data(
    976     self, data, warm_start, verbose, kwargs)
    977 end = time.time()
    978 self._solve_time = end - start

File ~\anaconda3\lib\site-packages\cvxpy\reductions\solvers\solving_chain.py:343, in SolvingChain.solve_via_data(self, problem, data, warm_start, verbose, solver_opts)
    307 def solve_via_data(self, problem, data, warm_start: bool = False, verbose: bool = False,
    308                    solver_opts={}):
    309     """Solves the problem using the data output by the an apply invocation.
    310 
    311     The semantics are:
   (...)
    341         a Solution object.
    342     """
--> 343     return self.solver.solve_via_data(data, warm_start, verbose,
    344                                       solver_opts, problem._solver_cache)

File ~\anaconda3\lib\site-packages\cvxpy\reductions\solvers\conic_solvers\scs_conif.py:321, in SCS.solve_via_data(self, data, warm_start, verbose, solver_opts, solver_cache)
    318         solver_opts['eps_abs'] = solver_opts.get('eps_abs', 1e-5)
    319         solver_opts['eps_rel'] = solver_opts.get('eps_rel', 1e-5)
--> 321     results = scs.solve(args, cones, verbose=verbose, **solver_opts)
    322     status = self.STATUS_MAP[results["info"]["status_val"]]
    324 if solver_cache is not None and status == s.OPTIMAL:

File ~\anaconda3\lib\site-packages\scs\__init__.py:133, in solve(probdata, cone, **kwargs)
    131 if kwargs.pop('gpu', False):  # False by default
    132   if not kwargs.pop('use_indirect', _USE_INDIRECT_DEFAULT):
--> 133     raise NotImplementedError(
    134         'GPU direct solver not yet available, pass `use_indirect=True`.')
    135   import _scs_gpu
    136   return _scs_gpu.csolve((m, n), Adata, Aindices, Acolptr, Pdata, Pindices,
    137                          Pcolptr, b, c, cone, warm, **kwargs)

NotImplementedError: GPU direct solver not yet available, pass `use_indirect=True`.

Thank you, your help is appreciated.

kalmarek commented 2 years ago

I think you should just follow the advice given by the error message ;)

hassanis commented 2 years ago

When I do, I get the following error message:

File ~\anaconda3\lib\site-packages\cvxpy\problems\problem.py:473, in Problem.solve(self, *args, **kwargs)
    471 else:
    472     solve_func = Problem._solve
--> 473 return solve_func(self, *args, **kwargs)

File ~\anaconda3\lib\site-packages\cvxpy\problems\problem.py:975, in Problem._solve(self, solver, warm_start, verbose, gp, qcp, requires_grad, enforce_dpp, **kwargs)
    971     s.LOGGER.info(
    972             'Invoking solver %s  to obtain a solution.',
    973             solving_chain.reductions[-1].name())
    974 start = time.time()
--> 975 solution = solving_chain.solve_via_data(
    976     self, data, warm_start, verbose, kwargs)
    977 end = time.time()
    978 self._solve_time = end - start

File ~\anaconda3\lib\site-packages\cvxpy\reductions\solvers\solving_chain.py:343, in SolvingChain.solve_via_data(self, problem, data, warm_start, verbose, solver_opts)
    307 def solve_via_data(self, problem, data, warm_start: bool = False, verbose: bool = False,
    308                    solver_opts={}):
    309     """Solves the problem using the data output by the an apply invocation.
    310 
    311     The semantics are:
   (...)
    341         a Solution object.
    342     """
--> 343     return self.solver.solve_via_data(data, warm_start, verbose,
    344                                       solver_opts, problem._solver_cache)

File ~\anaconda3\lib\site-packages\cvxpy\reductions\solvers\conic_solvers\scs_conif.py:321, in SCS.solve_via_data(self, data, warm_start, verbose, solver_opts, solver_cache)
    318         solver_opts['eps_abs'] = solver_opts.get('eps_abs', 1e-5)
    319         solver_opts['eps_rel'] = solver_opts.get('eps_rel', 1e-5)
--> 321     results = scs.solve(args, cones, verbose=verbose, **solver_opts)
    322     status = self.STATUS_MAP[results["info"]["status_val"]]
    324 if solver_cache is not None and status == s.OPTIMAL:

File ~\anaconda3\lib\site-packages\scs\__init__.py:136, in solve(probdata, cone, **kwargs)
    133     raise NotImplementedError(
    134         'GPU direct solver not yet available, pass `use_indirect=True`.')
    135   import _scs_gpu
--> 136   return _scs_gpu.csolve((m, n), Adata, Aindices, Acolptr, Pdata, Pindices,
    137                          Pcolptr, b, c, cone, warm, **kwargs)
    139 if kwargs.pop('use_indirect', _USE_INDIRECT_DEFAULT):
    140   import _scs_indirect

AttributeError: module '_scs' has no attribute 'csolve'
bodono commented 2 years ago

I'm not sure what's happening, but it might just be fixed by updating the SCS version. In any case, I do not recommend using the GPU solver for now.