Repository: ultralytics/ultralytics

Issue:
Ray Tune No available node types
### Search before asking

- [X] I have searched the YOLOv8 [issues](https://github.com/ultralytics/ultralytics/issues) and found no similar bug report.


### YOLOv8 Component

_No response_

### Bug

I try to use ray tune and get following
```
2023-06-06 10:20:14,936 INFO worker.py:1625 -- Started a local Ray instance.
2023-06-06 10:20:15,992 INFO tune.py:218 -- Initializing Ray automatically. For cluster usage or custom Ray initialization, call `ray.init(...)` before `Tuner(...)`.
/home/coder/.local/lib/python3.8/site-packages/ray/tune/experiment/experiment.py:170: UserWarning: The `local_dir` argument of `Experiment is deprecated. Use `storage_path` or set the `TUNE_RESULT_DIR` environment variable instead.
  warnings.warn(
(autoscaler +59s) Tip: use `ray status` to view detailed cluster status. To disable these messages, set RAY_SCHEDULER_EVENTS=0.
(autoscaler +59s) Error: No available node types can fulfill resource request {'CPU': 8.0}. Add suitable node types to this cluster to resolve this issue.
== Status ==
Current time: 2023-06-06 10:21:03 (running for 00:00:39.53)
Using AsyncHyperBand: num_stopped=0
Bracket: Iter 90.000: None | Iter 30.000: None | Iter 10.000: None
Logical resource usage: 0/2 CPUs, 0/2 GPUs (0.0/1.0 accelerator_type:A40)
```

### Environment

python 3.8.10
cuda 11.7

### Minimal Reproducible Example

```
from ultralytics import YOLO
from ray import tune

model = YOLO('yolov8l.yaml').load('yolov8l.pt')  # build from YAML and transfer weights

results = model.tune(data='data/localizer.yaml', 
                    space={
                        "lr0": tune.uniform(1e-5, 1e-1),
                        "lr1": tune.uniform(0.01, 1.0)},
                    train_args={
                        "epochs": 100,
                        "imgsz": 480, 
                        "batch": 128,
                        "device": 0}
                    )
```

### Additional

### Are you willing to submit a PR?

- [ ] Yes I'd like to help by submitting a PR!


Discussion:

Resolving patch:
diff --git a/ultralytics/yolo/engine/model.py b/ultralytics/yolo/engine/model.py
--- a/ultralytics/yolo/engine/model.py
+++ b/ultralytics/yolo/engine/model.py
@@ -9,8 +9,8 @@
                                   attempt_load_one_weight, guess_model_task, nn, yaml_model_load)
 from ultralytics.yolo.cfg import get_cfg
 from ultralytics.yolo.engine.exporter import Exporter
-from ultralytics.yolo.utils import (DEFAULT_CFG, DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, RANK, ROOT, callbacks,
-                                    is_git_dir, yaml_load)
+from ultralytics.yolo.utils import (DEFAULT_CFG, DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, NUM_THREADS, RANK, ROOT,
+                                    callbacks, is_git_dir, yaml_load)
 from ultralytics.yolo.utils.checks import check_file, check_imgsz, check_pip_update_available, check_yaml
 from ultralytics.yolo.utils.downloads import GITHUB_ASSET_STEMS
 from ultralytics.yolo.utils.torch_utils import smart_inference_mode
@@ -391,7 +391,7 @@ def tune(self,
              grace_period: int = 10,
              gpu_per_trial: int = None,
              max_samples: int = 10,
-             train_args: dict = {}):
+             train_args: dict = None):
         """
         Runs hyperparameter tuning using Ray Tune.
 
@@ -409,6 +409,8 @@ def tune(self,
         Raises:
             ModuleNotFoundError: If Ray Tune is not installed.
         """
+        if train_args is None:
+            train_args = {}
 
         try:
             from ultralytics.yolo.utils.tuner import (ASHAScheduler, RunConfig, WandbLoggerCallback, default_space,
@@ -443,7 +445,7 @@ def _tune(config):
         space['data'] = data
 
         # Define the trainable function with allocated resources
-        trainable_with_resources = tune.with_resources(_tune, {'cpu': 8, 'gpu': gpu_per_trial if gpu_per_trial else 0})
+        trainable_with_resources = tune.with_resources(_tune, {'cpu': NUM_THREADS, 'gpu': gpu_per_trial or 0})
 
         # Define the ASHA scheduler for hyperparameter search
         asha_scheduler = ASHAScheduler(time_attr='epoch',
@@ -454,7 +456,7 @@ def _tune(config):
                                        reduction_factor=3)
 
         # Define the callbacks for the hyperparameter search
-        tuner_callbacks = [WandbLoggerCallback(project='yolov8_tune')] if wandb else []
+        tuner_callbacks = [WandbLoggerCallback(project='YOLOv8-tune')] if wandb else []
 
         # Create the Ray Tune hyperparameter search tuner
         tuner = tune.Tuner(trainable_with_resources,
diff --git a/ultralytics/yolo/utils/__init__.py b/ultralytics/yolo/utils/__init__.py
--- a/ultralytics/yolo/utils/__init__.py
+++ b/ultralytics/yolo/utils/__init__.py
@@ -37,7 +37,7 @@
 VERBOSE = str(os.getenv('YOLO_VERBOSE', True)).lower() == 'true'  # global verbose mode
 TQDM_BAR_FORMAT = '{l_bar}{bar:10}{r_bar}'  # tqdm bar format
 LOGGING_NAME = 'ultralytics'
-MACOS, LINUX, WINDOWS = (platform.system() == x for x in ['Darwin', 'Linux', 'Windows'])  # environment booleans
+MACOS, LINUX, WINDOWS = (platform.system() == x for x in {'Darwin', 'Linux', 'Windows'})  # environment booleans
 HELP_MSG = \
     """
     Usage examples for running YOLOv8:


Test patch: