Open Faezehsgh opened 3 months ago
Hey sorry for the late response, I was on vacation and then forgot about it. Hmm I think we forced the install of the version anyway and it was working if I remember correctly. Tell me if this does not work for you I can try to reinstall it and run it.
Also while looking for any info on this ( Because the code was started by an intern in our team) , He also mentions a bugfix in rllib he added (for the version of the config).
In ray/rllib/utils/torch_utils.py replace convert_to_torch_tensor by this definition
def convert_to_torch_tensor(x: TensorStructType, device: Optional[str] = None):
"""Converts any struct to torch.Tensors.
x (any): Any (possibly nested) struct, the values in which will be
converted and returned as a new struct with all leaves converted
to torch tensors.
Returns:
Any: A new struct with the same structure as `stats`, but with all
values converted to torch Tensor types.
"""
def mapping(item):
# ELIAS ADD THIS BUGFIX
if item is None:
# returns None with dtype=np.obj
return np.asarray(item)
# Already torch tensor -> make sure it's on right device.
if torch.is_tensor(item):
return item if device is None else item.to(device)
# Special handling of "Repeated" values.
elif isinstance(item, RepeatedValues):
return RepeatedValues(
tree.map_structure(mapping, item.values), item.lengths, item.max_len
)
# Numpy arrays.
if isinstance(item, np.ndarray):
# Object type (e.g. info dicts in train batch): leave as-is.
if item.dtype == object:
return item
# Non-writable numpy-arrays will cause PyTorch warning.
elif item.flags.writeable is False:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
tensor = torch.from_numpy(item)
# Already numpy: Wrap as torch tensor.
else:
tensor = torch.from_numpy(item)
# Everything else: Convert to numpy, then wrap as torch tensor.
else:
tensor = torch.from_numpy(np.asarray(item))
# Floatify all float64 tensors.
if tensor.dtype == torch.double:
tensor = tensor.float()
return tensor if device is None else tensor.to(device)
return tree.map_structure(mapping, x)
Don't hesitate if you have further issues or question, I will add those in the readme
it seems that different version of requirements of the project conflict with each other. for example the gym and the ray library how did you solve these conflicts?