def _fit_gpu(self, Ciu_host, Cui_host, show_progress=True):
if not implicit.cuda.HAS_CUDA:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if self.dtype == np.float64:<EOL><INDENT>log.warning("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>self.item_factors = self.item_factors.astype(np.float32)<EOL>self.user_factors = self.user_factors.astype(np.float32)<EOL><DEDENT>Ciu = implicit.cuda.CuCSRMatrix(Ciu_host)<EOL>Cui = implicit.cuda.CuCSRMatrix(Cui_host)<EOL>X = implicit.cuda.CuDenseMatrix(self.user_factors.astype(np.float32))<EOL>Y = implicit.cuda.CuDenseMatrix(self.item_factors.astype(np.float32))<EOL>solver = implicit.cuda.CuLeastSquaresSolver(self.factors)<EOL>log.debug("<STR_LIT>", self.iterations)<EOL>with tqdm.tqdm(total=self.iterations, disable=not show_progress) as progress:<EOL><INDENT>for iteration in range(self.iterations):<EOL><INDENT>s = time.time()<EOL>solver.least_squares(Cui, X, Y, self.regularization, self.cg_steps)<EOL>progress.update(<NUM_LIT>)<EOL>solver.least_squares(Ciu, Y, X, self.regularization, self.cg_steps)<EOL>progress.update(<NUM_LIT>)<EOL>if self.fit_callback:<EOL><INDENT>self.fit_callback(iteration, time.time() - s)<EOL><DEDENT>if self.calculate_training_loss:<EOL><INDENT>loss = solver.calculate_loss(Cui, X, Y, self.regularization)<EOL>progress.set_postfix({"<STR_LIT>": loss})<EOL><DEDENT><DEDENT><DEDENT>if self.calculate_training_loss:<EOL><INDENT>log.info("<STR_LIT>", loss)<EOL><DEDENT>X.to_host(self.user_factors)<EOL>Y.to_host(self.item_factors)<EOL>
specialized training on the gpu. copies inputs to/from cuda device