# Using CVAE for robotic arm on CentOS Webots
###### tags: `Expriment Document`
## CUDA error
```
NVIDIA GeForce RTX 3090 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
If you want to use the NVIDIA GeForce RTX 3090 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
Traceback (most recent call last):
File "traj_dynamic_predict.py", line 378, in <module>
main(args)
File "traj_dynamic_predict.py", line 174, in main
iteration_err(loader, model, device, args.n_sample, args.max_len)
File "traj_dynamic_predict.py", line 329, in iteration_err
state_T, conf_T, seq_lens = model.inference(state, goal, max_len)
File "/home/hhlian/webots_simplify/optimized_long_horizon_task_search-master/opt_search/traj_dynamic/model_diversity.py", line 318, in inference
z = torch.randn(z_shape, device=self.device)
RuntimeError: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
```
* it seems like we have to install some GPU driver to make it run on 3090
* current solution is changing to use CPU by doing this
```
USE_CUDA = torch.cuda.is_available()
USE_CUDA = False
self.device = torch.device('cuda' if USE_CUDA else 'cpu')
```
* in file model_diversity.py and traj_dynamic_predict
## yaml/ numpy package problem
* webots in centos run on snap store
* we can't install new package on snap environment
* so we can't install yaml numpy
* need to change controller_interface to not have yaml and numpy
* yaml problem solve
* use pickle instead -> a python original package
* write a praser problem
```
import yaml
import pickle
import os
currtProblem = 10
path = "../../opt_search/traj_dynamic/sample/{}.yaml".format(currtProblem)
with open(path) as f:
data = yaml.load(f, Loader=yaml.FullLoader)
if (not os.path.isdir("sample")):
os.makedirs("sample")
with open("sample/{}.txt".format(currtProblem), "wb") as f:
pickle.dump(data,f)
print ("data_len = ", len(data))
for d in data:
print ("d_len = ", len(d))
for sub_d in d:
print ("sub_d_len = ", len(sub_d))
print (sub_d)
break
break
# print (d)
```
* remember to save file as binary and read file as binary
* read data in controller_interface
```
# load trajectories
path = "./sample/10.txt"
with open(path,"rb") as fp:
data = pickle.load(fp)
```
* how the data is stored?
```
- 0.07734820246696472 <- action
- 0.05489601939916611 <- action
- -0.13765864074230194 <- action
- 0.7427355051040649 <- action
- 0.061209239065647125 <- action
- 1.5092103481292725 <- action
- -1.5002007484436035 <- action
- 0.993532657623291 <- pred_endpoint_postion_x
- 1.1622333526611328 <- pred_endpoint_postion_y
- 0.6269657015800476 <- pred_endpoint_postion_z
- -0.10016382485628128 <- pred_endpoint_direction_x
- 0.9765028953552246 <- pred_endpoint_direction_y
- 0.09047442674636841 <- pred_endpoint_direction_z
- 0.6000000238418579 <- goal_postion_x
- 0.8640000224113464 <- goal_postion_y
- 0.10000000149011612 <- goal_postion_z
- 0.0 <- goal_direction_x
- 1.0 <- goal_direction_y
- 0.0 <- goal_direction_z
```
* numpy problem slove
* clip function
```
for index in range(len(a)):
a[index] = max(a_low[index], a[index])
a[index] = min(a_high[index], a[index])
return a
# return np.clip(a, a_low, a_high)
```
* norm

```
# dist = np.linalg.norm(endpoint-pred_endpoint)
# Get norm
norm_list = []
for index in range(len(endpoint)):
norm_list.append(endpoint[index] - pred_endpoint[index])
tmp_sum = 0
for index in range(len(norm_list)):
tmp_sum += norm_list[index] ** 2
dist = math.sqrt(tmp_sum)
```
* rad
```
# c2 = np.rad2deg(radian) <= 5
c2 = math.degrees(radian) <= 5
```
* arccos
```
# radian = np.arccos(dot/(mag_src*mag_trg))
radian = math.acos(dot/(mag_src*mag_trg))
```