Hello, This is my code with error in torch.manual_seed(myseed) and I have already added os.environ[‘CUDA_LAUNCH_BLOCKING’] = “1”. I don’t know how to fix it
My code
myseed = cfg[‘seed’] # set a random seed for reproducibility
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
np.random.seed(myseed)
torch.manual_seed(myseed)
random.seed(myseed)
if torch.cuda.is_available():
torch.cuda.manual_seed_all(myseed)
log_fw = open(f"{save_path}/log.txt", ‘w’) # open log file to save log outputs
def log(text): # define a logging function to trace the training process
print(text)
log_fw.write(str(text)+‘\n’)
log_fw.flush()
Are you getting the error directly when torch.manual_seed(myseed) is executed or are you running some code already beforehand?
In the former case, was the setup working before and if so what changed?
I don’t know how this config is used, but assuming the environment directly fails during the seeding without execution of any previous code I would suggest to delete the current environment and reinstall PyTorch into a new and empty virtual env.