2024-06-18 10:49:43 +08:00
|
|
|
|
# from joblib import load
|
|
|
|
|
#
|
|
|
|
|
# model = load('AgentPPO/reward_data.pkl')
|
|
|
|
|
#
|
|
|
|
|
# data = model['mean_episode_reward']
|
|
|
|
|
# print(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# import torch
|
|
|
|
|
#
|
|
|
|
|
# model_path = 'AgentDDPG/actor.pth'
|
|
|
|
|
#
|
|
|
|
|
# checkpoint = torch.load(model_path, map_location=torch.device('cuda'))
|
|
|
|
|
#
|
|
|
|
|
# # 如果.pth文件保存的是整个模型(包含模型结构和参数)
|
|
|
|
|
# model = checkpoint # 这里假设checkpoint直接就是模型实例,有时候可能需要model.load_state_dict(checkpoint['state_dict'])
|
|
|
|
|
|
|
|
|
|
# 如果.pth文件仅保存了state_dict(模型参数)
|
|
|
|
|
# model = YourModelClass() # 实例化你的模型
|
|
|
|
|
# model.load_state_dict(checkpoint)
|
|
|
|
|
|
2024-06-24 11:54:21 +08:00
|
|
|
|
# print(model)
|
2024-06-18 10:49:43 +08:00
|
|
|
|
|
2024-06-24 14:18:06 +08:00
|
|
|
|
# import pickle
|
|
|
|
|
#
|
|
|
|
|
# a = 'DDPG'
|
|
|
|
|
# b = 'PPO'
|
|
|
|
|
# c = 'SAC'
|
|
|
|
|
# d = 'TD3'
|
|
|
|
|
#
|
|
|
|
|
# a1 = '/reward_data.pkl'
|
|
|
|
|
# a2 = '/loss_data.pkl'
|
|
|
|
|
# a3 = '/test_data.pkl'
|
|
|
|
|
#
|
|
|
|
|
# filename = './Agent' + a + a3
|
|
|
|
|
#
|
|
|
|
|
# # 使用 'rb' 模式打开文件,读取二进制数据
|
|
|
|
|
# with open(filename, 'rb') as f:
|
|
|
|
|
# data = pickle.load(f)
|
|
|
|
|
#
|
|
|
|
|
# print(data)
|
2024-06-25 11:02:53 +08:00
|
|
|
|
# import json
|
|
|
|
|
# import numpy as np
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# def get_llm_action(index) -> np.ndarray:
|
|
|
|
|
# with open('data/llm_action.json', 'r') as file:
|
|
|
|
|
# data = json.load(file)
|
|
|
|
|
# normalized_index = index % len(data)
|
|
|
|
|
# action = np.array(data[normalized_index])
|
|
|
|
|
# return action
|
|
|
|
|
#
|
|
|
|
|
# data = get_llm_action(2)
|
|
|
|
|
# print(data)
|
2024-07-30 09:05:32 +08:00
|
|
|
|
import torch
|
2024-06-18 10:49:43 +08:00
|
|
|
|
|
2024-07-30 09:05:32 +08:00
|
|
|
|
|
|
|
|
|
def get_available_gpus():
|
|
|
|
|
if torch.cuda.is_available():
|
|
|
|
|
num_gpus = torch.cuda.device_count()
|
|
|
|
|
print(f"Number of available GPUs: {num_gpus}")
|
|
|
|
|
for i in range(num_gpus):
|
|
|
|
|
print(f"GPU {i}: {torch.cuda.get_device_name(i)}")
|
|
|
|
|
else:
|
|
|
|
|
print("No GPUs are available.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_available_gpus()
|