Hi ,
I am trying to run code which requires me to spawn multiple threads. I get “Illegal memory Access” error. I suppose it is due to one thread using memory of other thread. I also tried multiprocessing. Sadly, that didn’t help . I am attaching the code for reference. Any help will be appreciated
import cudf
import cupy as cp
from concurrent.futures import ThreadPoolExecutor
import torch
def parallel_gpu_operations(N):
"""
Args:
N: Number of rows
"""
total_gpus = torch.cuda.device_count()
cp.cuda.Device(cp.random.randint(total_gpus)).use() # Assign the GPU
x_cols = [f'X_{i}' for i in range(10)]
X_test = cp.random.randn(N,10)
y_test = cp.random.randn(N)
X_test = cudf.DataFrame(X_test,columns=x_cols)
X_test["y"] = y_test
low_pred_q = X_test["y"].quantile(0.4)
high_pred_q = X_test["y"].quantile(0.6)
X_test = X_test[(X_test["y"] <= low_pred_q) | (X_test["y"] >= high_pred_q)]
return (N,M,len(X_test))
NUM_PARALLEL_THREADS = 100
NUM_PROCESSES = 1000
with ThreadPoolExecutor(max_workers=NUM_PARALLEL_THREADS) as executor:
results = list(executor.map( parallel_gpu_operations,[(1000) for i in range(NUM_PROCESSES)]
))