fgerzer / apsis

Other
25 stars 4 forks source link

Error for apsis - apsis.utils.import_utils - WARNING - Module pymcmc could not be imported as it could not be found. #148

Open JiyuanZhang221 opened 7 years ago

JiyuanZhang221 commented 7 years ago

Hi everyone,

Here I run into a problem when running an apsis optimization shown as below:


import math
def f(x):
    return math.cos(x) + x/4 

""" Initilization"""
from apsis.models.parameter_definition import MinMaxNumericParamDef
param_defs = {'x': MinMaxNumericParamDef(0, 10)}

""" Define test1"""
from apsis.assistants.lab_assistant import PrettyLabAssistant
LAss = PrettyLabAssistant()
LAss.init_experiment("test1", "BayOpt", param_defs, minimization=True, optimizer_arguments={"initial_random_runs": 5, "mcmc": True})

"""Iteration"""
for i in range(30):
    candidate = LAss.get_next_candidate("test1")
    x = candidate.params['x']
    candidate.result = f(x)
    LAss.update("test1", candidate)

"""Show resutls"""
best_cand = LAss.get_best_candidate("test1")
print("Best result: " + str(best_cand.result))
print("with parameters: " + str(best_cand.params))
LAss.plot_result_per_step(['test1'])

An error came out as "apsis.utils.import_utils - WARNING - Module pymcmc could not be imported as it could not be found.".

I checked the file list under apsis folder and found there a "utilities" subfolder rather than a "utils" subfolder. I tried cloning the utilities folder and renamed the cloned folder as "utils". The error above did not show anymore but another error came out as:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Anaconda2\lib\site-packages\apsis\assistants\lab_assistant.py", line 52, in __init__
    self._init_directory_structure()
  File "D:\Anaconda2\lib\site-packages\apsis\assistants\lab_assistant.py", line 156, in _init_directory_structure
    ensure_directory_exists(self.lab_run_directory)
  File "D:\Anaconda2\lib\site-packages\apsis\utilities\file_utils.py", line 13, in ensure_directory_exists
    os.makedirs(directory)
  File "D:\Anaconda2\lib\os.py", line 157, in makedirs
    mkdir(name, mode)
WindowsError: [Error 123] : '/tmp/APSIS_WRITING\\2016-08-21_21:36:43'

I would really appreciate it if someone could help fix the problem.

Thanks.

ps: I used Anaconda on windows.


I changed 3rd line in import_utils.py from "logger = get_logger("apsis.utils.import_utils")" " to "logger = get_logger("apsis.utilities.import_utils")" but that still did not work.


Hi everyone,

Here I run into a problem when trying to install pymcmc

running build_ext customize MSVCCompiler customize MSVCCompiler using build_ext customize GnuFCompiler Found executable D:\minggw\bin\g77.exe gnu: no Fortran 90 compiler found gnu: no Fortran 90 compiler found Found executable D:\minggw\bin\g77.exe customize GnuFCompiler gnu: no Fortran 90 compiler found gnu: no Fortran 90 compiler found customize GnuFCompiler using build_ext building 'pymcmc.stochsearch' extension compiling C sources error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27

I would really appreciate it if someone could help fix the problem.

Thanks.

ps: I used Anaconda on windows.

fgerzer commented 7 years ago

Hi JiyuanZhang221,

in short, the issue you describe is due to v0.1.1 not supporting Windows. It should be fixed by setting the environment variable APSIS_LOG_ROOT to a valid folder, but I can't guarantee you won't run into other issues.

The longer explanation:

An error came out as "apsis.utils.import_utils - WARNING - Module pymcmc could not be imported as it could not be found.".

This is not an error unless using pymcmc for markov-chain monte carlo optimization. This is a way to optimize the parameters of the Gaussian process. While it promises slightly better results, the additional runtime makes it clunky and unnecessary. You don't need the package itself; just take care not to set "mcmc": True in optimizer_arguments.

I checked the file list under apsis folder and found there a "utilities" subfolder rather than a "utils" subfolder. I tried cloning the utilities folder and renamed the cloned folder as "utils".

This is not necessary. The line only specifies a name to use during the logging. It could also be called "import stuff" or anything. Calling it utils instead of utilities only makes it better to read.

WindowsError: [Error 123] : '/tmp/APSIS_WRITING\2016-08-21_21:36:43' This is the actual error. The issue is that, in logging, the directory to write out is set to /tmp/..., which does not exist on Windows. Since, with v0.1.1, we did not target Windows, we kept that path. To fix your error, you can either set the environment variable APSIS_LOG_ROOT to a valid folder, or change the '/tmp/APSIS_WRITING/logs' in that line to a valid folder.

As I said, installing pymcmc is not necessary (v0.2 will not include mcmc once released).

Lastly, please don't delete things from your issues. Without me getting a copy by mail, I wouldn't have been able to find the original error. I've re-added them to your post.

JiyuanZhang221 commented 7 years ago

Thank you very much fdiehl for the detailed response. I've added the enviroment variable to a valid folder but the error still exists. I think I'd better switch to a Linux system in order to resolve the problem. Thanks again.