# Hyperparameter Tuning with specified session directory (!=/tmp/ray/)

**URL:** <https://discuss.ray.io/t/hyperparameter-tuning-with-specified-session-directory-tmp-ray/8866>\
**Category:** Uncategorized\
**Created:** [January 6, 2023, 9:22am UTC](https://discuss.ray.io/t/hyperparameter-tuning-with-specified-session-directory-tmp-ray/8866 "2023-01-06T09:22:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stillsen](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@stillsen](https://discuss.ray.io/u/stillsen)\
**Post date:** [January 6, 2023, 9:22am UTC](https://discuss.ray.io/t/hyperparameter-tuning-with-specified-session-directory-tmp-ray/8866/1 "2023-01-06T09:22:54Z")

</div>

Hi,  
I am using Ray to tune the hyper-paramters of a pytorch model.  
The storage capacity on /tmp is limited, thus I want to **specify the session directory** (i.e. /tmp/ray → /my\_directory) **when working with tune.Tuner()**.  
I [found](https://docs.ray.io/en/latest/ray-core/configure.html#temp-dir-log-files) that I could specify a parameter --temp-dir or pass it somehow to ray.init().

However, I neither call ray nor ray.init() and simply do not know where to set the session directory. Any simple tips?  
So far I am basically passing an object of a tune.trainable to tune.Tuner() and call tuner.fit().

Thanks for any advise!  
stillsen

---

<div class="post-metadata">

**Author:** ![Yard1](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yard1/32/508_2.png) [@Yard1](https://discuss.ray.io/u/Yard1)\
**Post date:** [January 6, 2023, 11:04am UTC](https://discuss.ray.io/t/hyperparameter-tuning-with-specified-session-directory-tmp-ray/8866/2 "2023-01-06T11:04:21Z")

</div>

You most likely want to set the `local_dir` argument in `RunConfig` - [Ray AIR API — Ray 2.2.0](https://docs.ray.io/en/latest/ray-air/package-ref.html#ray.air.config.RunConfig). This is where all the results and checkpoints will be saved to.

---

<div class="post-metadata">

**Author:** ![stillsen](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@stillsen](https://discuss.ray.io/u/stillsen)\
**Post date:** [January 6, 2023, 11:58am UTC](https://discuss.ray.io/t/hyperparameter-tuning-with-specified-session-directory-tmp-ray/8866/3 "2023-01-06T11:58:33Z")

</div>

Thanks for your reply.

I forgot to mention that I indeed have set local\_dir to /my\_directory. I did this because of “No space left on device” earlier. Both locations (~/ray\_results/ and /tmp/ray) have limited storage capacity.

I thought that active trials are temporarily stored in /tmp/ray and that this might cause the error.

error log:  
Traceback (most recent call last):  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/tune/tuner.py”, line 272, in fit  
return self.\_local\_tuner.fit()  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/tune/impl/tuner\_internal.py”, line 420, in fit  
analysis = self.\_fit\_internal(trainable, param\_space)  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/tune/impl/tuner\_internal.py”, line 532, in \_fit\_internal  
analysis = run(  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/tune/tune.py”, line 388, in run  
\_ray\_auto\_init()  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/tune/tune.py”, line 892, in \_ray\_auto\_init  
ray.init()  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/\_private/client\_mode\_hook.py”, line 105, in wrapper  
return func(\*args, \*\*kwargs)  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/\_private/worker.py”, line 1567, in init  
hook()  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/tune/registry.py”, line 241, in flush  
self.references[k] = ray.put(v)  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/\_private/client\_mode\_hook.py”, line 105, in wrapper  
return func(\*args, \*\*kwargs)  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/\_private/worker.py”, line 2375, in put  
object\_ref = worker.put\_object(value, owner\_address=serialize\_owner\_address)  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/\_private/worker.py”, line 619, in put\_object  
self.core\_worker.put\_serialized\_object\_and\_increment\_local\_ref(  
File “python/ray/\_raylet.pyx”, line 1708, in ray.\_raylet.CoreWorker.put\_serialized\_object\_and\_increment\_local\_ref  
File “python/ray/\_raylet.pyx”, line 1597, in ray.\_raylet.CoreWorker.\_create\_put\_buffer  
File “python/ray/\_raylet.pyx”, line 193, in ray.\_raylet.check\_status  
ray.exceptions.OutOfDiskError: Local disk is full  
The object cannot be created because the local object store is full and the local disk’s utilization is over capacity (95% by default).Tip: Use `df` on this node to check disk usage and `ray memory` to check object store memory usage.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):  
File “01\_train\_resnet18\_SCV\_P65.py”, line 241, in   
analysis = tuner.fit()  
File “/home/stiller/anaconda3/envs/CUR2/lib/python3.8/site-packages/ray/tune/tuner.py”, line 274, in fit  
raise TuneError(  
ray.tune.error.TuneError: The Ray Tune run failed. Please inspect the previous error messages for a cause. After fixing the issue, you can restart the run from scratch or continue this run. To continue this run, you can use `tuner = Tuner.restore("/beegfs/stiller/PatchCROP_all/Output/P_65_resnet18_SCV_no_test_L1_ALB_TR10/Tuning_resnet18_SCV_no_test_all_bayes_L1_ALB_f1_65_TR10")`.  
(raylet) [2023-01-06 12:51:59,271 E 38384 38401] (raylet) dlmalloc.cc:202: Out of disk space with fallocate error: No space left on device  
(raylet) [2023-01-06 12:51:59,271 E 38384 38401] (raylet) dlmalloc.cc:202: Out of disk space with fallocate error: No space left on device  
(raylet) [2023-01-06 12:51:59,271 E 38384 38401] (raylet) object\_lifecycle\_manager.cc:214: Plasma fallback allocator failed, likely out of disk space.

---

<div class="post-metadata">

**Author:** ![Yard1](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yard1/32/508_2.png) [@Yard1](https://discuss.ray.io/u/Yard1)\
**Post date:** [January 6, 2023, 12:11pm UTC](https://discuss.ray.io/t/hyperparameter-tuning-with-specified-session-directory-tmp-ray/8866/4 "2023-01-06T12:11:47Z")

</div>

You can call `ray.init()` with your arguments (`temp_dir`) before calling `Trainer.fit()` - it will inherit the current Ray session.

---

<div class="post-metadata">

**Author:** ![stillsen](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@stillsen](https://discuss.ray.io/u/stillsen)\
**Post date:** [January 9, 2023, 1:49pm UTC](https://discuss.ray.io/t/hyperparameter-tuning-with-specified-session-directory-tmp-ray/8866/5 "2023-01-09T13:49:52Z")

</div>

Thank you for your support! ray.init(\_temp\_dir=‘/my\_directory’) does the trick.
