Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU not in use Error #706

Open
Kendrick-Stein opened this issue May 27, 2024 · 4 comments
Open

GPU not in use Error #706

Kendrick-Stein opened this issue May 27, 2024 · 4 comments

Comments

@Kendrick-Stein
Copy link

I have written the following script to simulate one random object falling into another, and I come across the following question. After I ran the code, I use 'nvidia-smi' to check whether if the code uses cuda, and find out that no gpu is utilized.
I wonder why could it happen.

@Kendrick-Stein
Copy link
Author

image the weird thing about it is that after I ran the code, the fan is howling like crazy, yet no sign of gpu being used.

@Kendrick-Stein
Copy link
Author

Kendrick-Stein commented May 27, 2024

This is the code I use:

from tdw.controller import Controller
from tdw.tdw_utils import TDWUtils
from tdw.add_ons.third_person_camera import ThirdPersonCamera
from tdw.add_ons.image_capture import ImageCapture
from typing import List, Dict, Tuple
import random
import numpy as np
import json

file_path = "your_path_to_the_model_core_json/models_core.json"
with open(file_path, 'r', encoding='utf-8') as file:
    data = json.load(file)
key_list = data['records'].keys()
model_list = []
for key in key_list:
    model_list.append(key)
# print(model_list)


c = Controller()
commands = [{"$type": "set_screen_size",
                     "width": 512,
                     "height": 512},
                    {"$type": "set_render_quality",
                     "render_quality": 5},
                    {"$type": "set_physics_solver_iterations",
                     "iterations": 32},
                    {"$type": "set_vignette",
                     "enabled": False},
                    {"$type": "set_shadow_strength",
                     "strength": 1.0},
                    {"$type": "set_sleep_threshold",
                     "sleep_threshold": 0.01}]
c.communicate(commands)
def get_random_avatar_position(radius_min: float,
                                   radius_max: float,
                                   y_min: float,
                                   y_max: float,
                                   center: Dict[str, float],
                                   angle_min: float = 0,
                                   angle_max: float = 360,
                                   reflections: bool = False,
                                   ) -> Dict[str, float]:
    """
    :param radius_min: The minimum distance from the center.
    :param radius_max: The maximum distance from the center.
    :param y_min: The minimum y positional coordinate.
    :param y_max: The maximum y positional coordinate.
    :param center: The centerpoint.
    :param angle_min: The minimum angle of rotation around the centerpoint.
    :param angle_max: The maximum angle of rotation around the centerpoint.

    :return: A random position for the avatar around a centerpoint.
    """

    a_r = random.uniform(radius_min, radius_max)
    a_x = center["x"] + a_r
    a_z = center["z"] + a_r
    theta = np.radians(random.uniform(angle_min, angle_max))
    if reflections:
        theta2 = random.uniform(angle_min+180, angle_max+180)
        theta = random.choice([theta, theta2])
    a_y = random.uniform(y_min, y_max) + center["y"]
    a_x_new = np.cos(theta) * (a_x - center["x"]) - np.sin(theta) * (a_z - center["z"]) + center["x"]
    a_z_new = np.sin(theta) * (a_x - center["x"]) + np.cos(theta) * (a_z - center["z"]) + center["z"]
    a_x = a_x_new
    a_z = a_z_new

    return {"x": a_x, "y": a_y, "z": a_z}



camera = ThirdPersonCamera(position={"x": -3, "y": 1.1, "z": 0.5},
                           look_at={"x": 0, "y": 0, "z": 0})
capture = ImageCapture(avatar_ids=[camera.avatar_id], 
                                                                                                    
                                                                "_category","_mask",
                                                                "_depth","_normals","_flow","_albedo"])
c.add_ons.extend([camera,capture])
commands = [TDWUtils.create_empty_room(12, 12)]
commands.extend(c.get_add_physics_object(model_name=model_list[random.randint(0,len(model_list))],
                                         object_id=c.get_unique_id(),
                                         position={"x": 0, "y": 2, "z": 0}
                                                                             ))
commands.extend(c.get_add_physics_object(model_name=model_list[random.randint(0,len(model_list))],
                                         object_id=c.get_unique_id(),
                                         position={"x": 0, "y": 0, "z": 0}
                                         ))
# commands.extend(c.get_add_hdri_skybox)
c.communicate(commands)
for i in range(200):
    c.communicate([])
c.communicate({"$type": "terminate"})

@Kendrick-Stein
Copy link
Author

image I have tried the solutions suggested in https://github.com//issues/549#issuecomment-1509054639 but it won't work.

@alters-mit
Copy link
Member

Try setting launch_build=False and then launch the build manually. If that doesn't work, send the Player log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants