def _cuda_fit(self, X, Y, bfs_threshold, remain_trees, lock): self._cuda_forest = cdRF(n_estimators = 1, bootstrap = self.bootstrap, max_features = self.max_features) #allocate resource self._cuda_forest.fit_init(X, Y) f = self._cuda_forest while True: lock.acquire() if remain_trees.value == 0: lock.release() break remain_trees.value -= 1 lock.release() tree = RandomClassifierTree(f) si, n_samples = f._get_sorted_indices(f.sorted_indices) tree.fit(f.samples, f.target, si, n_samples) f._trees.append(tree) #release the resource self._cuda_forest.fit_release()
def run(self): reload(util) driver.init() ctx = driver.Device(self.gpu_id).make_context() X = self.X Y = self.Y bootstrap = self.bootstrap max_features = self.max_features bfs_threshold = self.bfs_threshold remain_trees = self.remain_trees lock = self.lock trees = list() forest = cdRF(n_estimators=1, bootstrap=bootstrap, max_features=max_features) forest.fit_init(X, Y) while True: lock.acquire() if remain_trees.value == 0: lock.release() break remain_trees.value -= 1 lock.release() util.log_info("CUDA gets 1 job") tree = RandomClassifierTree(forest) si, n_samples = forest._get_sorted_indices(forest.sorted_indices) tree.fit(forest.samples, forest.target, si, n_samples) trees.append(tree) forest.fit_release() self.result_queue.put(trees) ctx.detach() del ctx util.log_info("GPU DONE")
def run(self): reload(util) driver.init() ctx = driver.Device(self.gpu_id).make_context() X = self.X Y = self.Y bootstrap = self.bootstrap max_features = self.max_features bfs_threshold = self.bfs_threshold remain_trees = self.remain_trees lock = self.lock trees = list() forest = cdRF(n_estimators = 1, bootstrap = bootstrap, max_features = max_features) forest.fit_init(X, Y) while True: lock.acquire() if remain_trees.value == 0: lock.release() break remain_trees.value -= 1 lock.release() util.log_info("CUDA gets 1 job") tree = RandomClassifierTree(forest) si, n_samples = forest._get_sorted_indices(forest.sorted_indices) tree.fit(forest.samples, forest.target, si, n_samples) trees.append(tree) forest.fit_release() self.result_queue.put(trees) ctx.detach() del ctx util.log_info("GPU DONE")